From patchwork Mon Sep 24 09:19:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 147341 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp484378lji; Mon, 24 Sep 2018 02:20:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV60SrP4C0JM32NwLRs3BW54RSTASn6ju4H4rUiIWBR8vHxbxpbfksuJo6xn55A7j+vy6QXuD X-Received: by 2002:a63:3c46:: with SMTP id i6-v6mr2320488pgn.286.1537780808218; Mon, 24 Sep 2018 02:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537780808; cv=none; d=google.com; s=arc-20160816; b=Q5NA53iPXh7C3DwcYXUjX5uSWqYOWoH2FoMGZlJT307U/sfmSSZ0h60+7G3gXNA5sm cmgtR5Sc+qZtRTw8RMij63nfLmd+psEJ2VJa4upRNok4p52VFsHMXfaUgcZ8LMAfvMry vKBjMqELwVlLZPVRsTL7xU6rbD4k9tI9wAe258kJ2MFZR6ul70aBpTeEalxCdisoMe4E sU/v3PxzBQOylsULd/HOX9Ip0H8HI5INySaoiSkZR1eoDIBQxyM+XDOaLQXrb4czUCEz fxuWtvNBmOT2pw+5PCyUKuiD53tMEu675Ww45/VTPfAm2SnHCp53eqqla42bKK3HnSNL u+sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=FMx9tLbI/vKscYYOFsAedr8t0qJhKinYsOCzl3TdY3U=; b=tGz6n5zjBZOgTZCBt55yt23fVY9nCpoXSM1dmvustTeP4bB/nhB8E626iw6K+s8Uao LvI4PbNZUgDQDTAsZhzE8K72jl+YabZPgtlKN9wtc68p0Gjma8YcK2tJYJGntcE1pMen SJrkBaN14kjnln0rVRPd4Sm3UrUME8aGDCjZeJNeA3RXLa1tQhWsOackhI/UQ/Ne+BG8 iQ6NRCuAuBDLNVTg7K/Zfl13+6IOBXF6IkQmLLRmO8L4s0oUt7LUNXc6sXrUMA6TMI8E IQuSvm84O5Gd7RrYGnSs+10FXFjxHlEixFKm4WgsT2UeGZe42CRTc+63vACnxITaLh9k 7mdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WYkko1Bs; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11-v6si3400717pls.76.2018.09.24.02.20.07; Mon, 24 Sep 2018 02:20:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WYkko1Bs; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbeIXPVO (ORCPT + 5 others); Mon, 24 Sep 2018 11:21:14 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35315 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726956AbeIXPVN (ORCPT ); Mon, 24 Sep 2018 11:21:13 -0400 Received: by mail-lf1-f67.google.com with SMTP id r191-v6so3489992lff.2 for ; Mon, 24 Sep 2018 02:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=FMx9tLbI/vKscYYOFsAedr8t0qJhKinYsOCzl3TdY3U=; b=WYkko1BsWGd+2OpF3/xm7Tozx1v79Yq89dAromGFqtmH6py6EzYhnw5P5akBXqPdtp haRzTp5l/M8w/47EwA7PYFBwukWVuc/7M5xkwcLQ3fXiQyqEuuIZtKlx7ACYBNJyYoVX v+eu4eYQsMSyuGjvMciAX9GU5mWXw0RR6I2vU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FMx9tLbI/vKscYYOFsAedr8t0qJhKinYsOCzl3TdY3U=; b=Xz9CrS7gmW4rxBS36T8mlQSja0afd4rZVhAIcJ3XLrYtAYJDtBNSAOKytbKd62LP5U z8gkGpSUHd51uLZFXO8GtJm62thNyyK0XS/d9gU+0VkThumpWpvBGnB9EdffkZMqj3eC EcJS0E9GasQ+fTfCEECYUv50CTNKhpXnzhvr6DE3Yo3rkhD4DouANQHKugRMsPyBBsZ/ UN4RDnDmW9w4YDBfV+L+K841ZMuw7K7wUjISTpPKHYesQ4a+i7fYA1SOGjeKk9ah7oFM OJujospIh6HxOKifXJYa8/yid+oAzP7grqOYOLz+SJrZUTfLokEXBqT8AyKBzNkxIL92 gx7A== X-Gm-Message-State: APzg51BiBc8+ChZVouCYzd7vRjmPEyIyExWZYXNwhKMBSgdd7CvKNfrK w4COckWA6g+cPnD0vCaC0RwjYC/Ju4c= X-Received: by 2002:a19:6619:: with SMTP id a25-v6mr5939481lfc.62.1537780804020; Mon, 24 Sep 2018 02:20:04 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id y17-v6sm6406569ljd.42.2018.09.24.02.20.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Sep 2018 02:20:02 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Tony Lindgren , linux-omap@vger.kernel.org Subject: [PATCH] mmc: omap_hsmmc: Kill off cover detection Date: Mon, 24 Sep 2018 11:19:59 +0200 Message-Id: <20180924091959.8587-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Cover detection appears to be a feature protecting the SD card on mobile phones with a slide-cover, such as some Nokia phones. The idea seems to be to not allow access to the SD card when the cover is open. It is only usable with platform data from board files, but no board file in the kernel is using it, yet it takes up a sizeable chunk of code in the OMAP HSMMC driver. Since we do not add new board files for the OMAPs any target that need this should anyway reimplement it properly using the device tree, so delete this legacy code. The driver is marked as orphan in MAINTAINERS by the way. Cc: Tony Lindgren Cc: linux-omap@vger.kernel.org Signed-off-by: Linus Walleij --- drivers/mmc/host/omap_hsmmc.c | 120 +---------------------- include/linux/platform_data/hsmmc-omap.h | 1 - 2 files changed, 2 insertions(+), 119 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 071693ebfe18..bfa803d337a4 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -198,7 +198,6 @@ struct omap_hsmmc_host { struct dma_chan *rx_chan; int response_busy; int context_loss; - int protect_card; int reqs_blocked; int req_in_progress; unsigned long clk_rate; @@ -207,15 +206,6 @@ struct omap_hsmmc_host { #define HSMMC_SDIO_IRQ_ENABLED (1 << 1) /* SDIO irq enabled */ struct omap_hsmmc_next next_data; struct omap_hsmmc_platform_data *pdata; - - /* return MMC cover switch state, can be NULL if not supported. - * - * possible return values: - * 0 - closed - * 1 - open - */ - int (*get_cover_state)(struct device *dev); - int (*card_detect)(struct device *dev); }; @@ -233,13 +223,6 @@ static int omap_hsmmc_card_detect(struct device *dev) return mmc_gpio_get_cd(host->mmc); } -static int omap_hsmmc_get_cover_state(struct device *dev) -{ - struct omap_hsmmc_host *host = dev_get_drvdata(dev); - - return mmc_gpio_get_cd(host->mmc); -} - static int omap_hsmmc_enable_supply(struct mmc_host *mmc) { int ret; @@ -484,22 +467,13 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) return 0; } -static irqreturn_t omap_hsmmc_cover_irq(int irq, void *dev_id); - static int omap_hsmmc_gpio_init(struct mmc_host *mmc, struct omap_hsmmc_host *host, struct omap_hsmmc_platform_data *pdata) { int ret; - if (gpio_is_valid(pdata->gpio_cod)) { - ret = mmc_gpio_request_cd(mmc, pdata->gpio_cod, 0); - if (ret) - return ret; - - host->get_cover_state = omap_hsmmc_get_cover_state; - mmc_gpio_set_cd_isr(mmc, omap_hsmmc_cover_irq); - } else if (gpio_is_valid(pdata->gpio_cd)) { + if (gpio_is_valid(pdata->gpio_cd)) { ret = mmc_gpio_request_cd(mmc, pdata->gpio_cd, 0); if (ret) return ret; @@ -781,9 +755,6 @@ static void send_init_stream(struct omap_hsmmc_host *host) int reg = 0; unsigned long timeout; - if (host->protect_card) - return; - disable_irq(host->irq); OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK); @@ -804,29 +775,6 @@ static void send_init_stream(struct omap_hsmmc_host *host) enable_irq(host->irq); } -static inline -int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host) -{ - int r = 1; - - if (host->get_cover_state) - r = host->get_cover_state(host->dev); - return r; -} - -static ssize_t -omap_hsmmc_show_cover_switch(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev); - struct omap_hsmmc_host *host = mmc_priv(mmc); - - return sprintf(buf, "%s\n", - omap_hsmmc_cover_is_closed(host) ? "closed" : "open"); -} - -static DEVICE_ATTR(cover_switch, S_IRUGO, omap_hsmmc_show_cover_switch, NULL); - static ssize_t omap_hsmmc_show_slot_name(struct device *dev, struct device_attribute *attr, char *buf) @@ -1247,44 +1195,6 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd) return ret; } -/* Protect the card while the cover is open */ -static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host) -{ - if (!host->get_cover_state) - return; - - host->reqs_blocked = 0; - if (host->get_cover_state(host->dev)) { - if (host->protect_card) { - dev_info(host->dev, "%s: cover is closed, " - "card is now accessible\n", - mmc_hostname(host->mmc)); - host->protect_card = 0; - } - } else { - if (!host->protect_card) { - dev_info(host->dev, "%s: cover is open, " - "card is now inaccessible\n", - mmc_hostname(host->mmc)); - host->protect_card = 1; - } - } -} - -/* - * irq handler when (cell-phone) cover is mounted/removed - */ -static irqreturn_t omap_hsmmc_cover_irq(int irq, void *dev_id) -{ - struct omap_hsmmc_host *host = dev_id; - - sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); - - omap_hsmmc_protect_card(host); - mmc_detect_change(host->mmc, (HZ * 200) / 1000); - return IRQ_HANDLED; -} - static void omap_hsmmc_dma_callback(void *param) { struct omap_hsmmc_host *host = param; @@ -1555,24 +1465,7 @@ static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req) BUG_ON(host->req_in_progress); BUG_ON(host->dma_ch != -1); - if (host->protect_card) { - if (host->reqs_blocked < 3) { - /* - * Ensure the controller is left in a consistent - * state by resetting the command and data state - * machines. - */ - omap_hsmmc_reset_controller_fsm(host, SRD); - omap_hsmmc_reset_controller_fsm(host, SRC); - host->reqs_blocked += 1; - } - req->cmd->error = -EBADF; - if (req->data) - req->data->error = -EBADF; - req->cmd->retries = 0; - mmc_request_done(mmc, req); - return; - } else if (host->reqs_blocked) + if (host->reqs_blocked) host->reqs_blocked = 0; WARN_ON(host->mrq != NULL); host->mrq = req; @@ -1921,7 +1814,6 @@ static struct omap_hsmmc_platform_data *of_get_hsmmc_pdata(struct device *dev) pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT; pdata->gpio_cd = -EINVAL; - pdata->gpio_cod = -EINVAL; pdata->gpio_wp = -EINVAL; if (of_find_property(np, "ti,non-removable", NULL)) { @@ -2125,8 +2017,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev) if (!ret) mmc->caps |= MMC_CAP_SDIO_IRQ; - omap_hsmmc_protect_card(host); - mmc_add_host(mmc); if (mmc_pdata(host)->name != NULL) { @@ -2134,12 +2024,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev) if (ret < 0) goto err_slot_name; } - if (host->get_cover_state) { - ret = device_create_file(&mmc->class_dev, - &dev_attr_cover_switch); - if (ret < 0) - goto err_slot_name; - } omap_hsmmc_debugfs(mmc); pm_runtime_mark_last_busy(host->dev); diff --git a/include/linux/platform_data/hsmmc-omap.h b/include/linux/platform_data/hsmmc-omap.h index 73d9098ada2d..c055d7eda085 100644 --- a/include/linux/platform_data/hsmmc-omap.h +++ b/include/linux/platform_data/hsmmc-omap.h @@ -71,7 +71,6 @@ struct omap_hsmmc_platform_data { char *version; int gpio_cd; /* gpio (card detect) */ - int gpio_cod; /* gpio (cover detect) */ int gpio_wp; /* gpio (write protect) */ /* if we have special card, init it using this callback */ void (*init_card)(struct mmc_card *card);