From patchwork Mon Nov 12 14:12:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150839 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3190742ljp; Mon, 12 Nov 2018 06:12:52 -0800 (PST) X-Google-Smtp-Source: AJdET5cD5ICyKtiy5c7iR1chFiXRITTT2CQFB+j/KVA8rGcKkTST3/r16d6Te0nNRs0qn7IaP3th X-Received: by 2002:a62:37c7:: with SMTP id e190-v6mr1033426pfa.145.1542031972259; Mon, 12 Nov 2018 06:12:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031972; cv=none; d=google.com; s=arc-20160816; b=XJGO11iwJzBg1HuZ2JDzsgp89kEsHkrV/jP3vhSaEr6xwRUP+OC7GiH2ZfOWqtU3nm MvE7NfMTK28EWupk1P2h+/HQfbVMa/N0lrLka/2X8VVID28hlbmotE7BNy56QNC+1PqH ZgzsFnAJM9kYr9fxYYp227XuCEF6n+3yqWNz2gC6hrrXTpWSuMLlhqk+4ncP1TmB/mxU 6oEl9pOqeojrVgHygqHBx5cxjy3hnBPvzQb/9OCoQOmG6k+9mJNBKgh3Ce9lycVgKMiw qs76TFaXdbcoQ0qr50tnYHZMpPnvtF4ENv/NpR4OnKC6k0znmVH7Um89b44baYzq/PoF eDEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=j82EKe+wRAgT6Athn6eo09la18zaAjt/fVKoE3mDKu4=; b=e5H/qsU8sBdv/DQb/NNQY3pDgnyj1TaHakehGP0FyVgsPr139BJhuuM4FdJ2CbdMeL pPl+syDDD00GuNR/c4CG2Mi7HOvskZE7M6kelit/CneYjjVu97/qp+bZ9EnbDSzAW+VN VZeyPG0oK8FnJPhP8P9bKJ5/LJQIOM2OpkxwRbBfOH99jLtGQWw2SUHiw/xoG+somM9q b5dQr25eJMytjBQ3Wj7P9xdWpkHFUj3+meS+fh9hwvF6fojIYA9Y+K0WbwtYBvMnRq57 55plwVtwIqqOKa5xMUpC6fz2/GQPmjtk692RN5U1XZvZwOvt9Oaa8gN5np4rKqkWQw9T beww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iG4r+mLK; 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 h68-v6si19277640pfb.142.2018.11.12.06.12.52; Mon, 12 Nov 2018 06:12:52 -0800 (PST) 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=iG4r+mLK; 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 S1728505AbeKMAGR (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:17 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41927 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbeKMAGR (ORCPT ); Mon, 12 Nov 2018 19:06:17 -0500 Received: by mail-lj1-f194.google.com with SMTP id z80-v6so7731281ljb.8 for ; Mon, 12 Nov 2018 06:12:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j82EKe+wRAgT6Athn6eo09la18zaAjt/fVKoE3mDKu4=; b=iG4r+mLK5eTJhEUIkhoxf8pviJcETEBujKpfk0OBjA7q/2KEpCKFis2V2aaF7KDwYm b4fBAofgUsLVhnv1ezOvIXhZr4WZ/yLLdlfByJq+p1QS/bTHkDtTIbnRyS1tnmXVq4tI G3OsyRlEicbE5+bWwwld3NcZTQi2OCkoBl6G8= 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:in-reply-to :references; bh=j82EKe+wRAgT6Athn6eo09la18zaAjt/fVKoE3mDKu4=; b=DFkaKOyDS2VBfCJRRQQkB8muVY114rkHaHgiI0PvYAvg3bJG5XLq6to7CFiBoJOLUL aHCvvl2Ot1N3FhkxGu3ubSasnBr7mf0RJ2rX4EkdND08gVS1RHYq1KCxv2jctgBhuOz7 JziT3b1pew2cNRXpd9l5u1tT6vM5mJH/lKgqh4RqUPJvvBR4YfcVB75e4esw7Xt9F+3B qZypuDNiF/H/mjwJ3nOCcShIlGB9LxX3tlvsag/ZNtW1MgPuL5YQZDxlMRV/xI0B/xPz jrJ/Ekn3xN7PEHGITR0BuOYjIFj5Cm8XEcPQW/48/Vqn/OhuN/rKW6V5Ub8264nLdZfi Iedw== X-Gm-Message-State: AGRZ1gKjIuR/o6I7EsxasnP8gYKAT9b01/NRcNtxSqaFfq3r2rX9O0vi SqPm4EJHeMWO9fIRXK2CVGk7UfGKx4JiLw== X-Received: by 2002:a2e:5246:: with SMTP id g67-v6mr777260ljb.73.1542031968565; Mon, 12 Nov 2018 06:12:48 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.12.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:12:47 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij Subject: [PATCH 01/10] mmc: slot-gpio: Allocate GPIO labels dynamically Date: Mon, 12 Nov 2018 15:12:30 +0100 Message-Id: <20181112141239.19646-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The use of string pointers in the MMC slot GPIO context is pretty dubious, allocating some 2*len extra bytes for each label of the ro and wp pins. Tidy this up using kasprintf() with dynamic allocation of labels for these strings. Signed-off-by: Linus Walleij --- drivers/mmc/core/slot-gpio.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.17.2 diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 86803a3a04dc..e5bb86b02373 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -27,8 +27,8 @@ struct mmc_gpio { bool override_cd_active_level; irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); char *ro_label; + char *cd_label; u32 cd_debounce_delay_ms; - char cd_label[]; }; static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) @@ -45,15 +45,19 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) int mmc_gpio_alloc(struct mmc_host *host) { - size_t len = strlen(dev_name(host->parent)) + 4; struct mmc_gpio *ctx = devm_kzalloc(host->parent, - sizeof(*ctx) + 2 * len, GFP_KERNEL); + sizeof(*ctx), GFP_KERNEL); if (ctx) { - ctx->ro_label = ctx->cd_label + len; ctx->cd_debounce_delay_ms = 200; - snprintf(ctx->cd_label, len, "%s cd", dev_name(host->parent)); - snprintf(ctx->ro_label, len, "%s ro", dev_name(host->parent)); + ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL, + "%s cd", dev_name(host->parent)); + if (!ctx->cd_label) + return -ENOMEM; + ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL, + "%s ro", dev_name(host->parent)); + if (!ctx->ro_label) + return -ENOMEM; host->slot.handler_priv = ctx; host->slot.cd_irq = -EINVAL; } From patchwork Mon Nov 12 14:12:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150840 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3190838ljp; Mon, 12 Nov 2018 06:12:57 -0800 (PST) X-Google-Smtp-Source: AJdET5c8SMlw7OFSdgzyyhG+PKQg3P/UucQkh6lK/NlJnvZcn+AHU6AJbuf6Vipp7n+kUWyCFTzn X-Received: by 2002:a62:e10c:: with SMTP id q12-v6mr1033264pfh.75.1542031977067; Mon, 12 Nov 2018 06:12:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031977; cv=none; d=google.com; s=arc-20160816; b=bnFbkbxodtzs6HneWtmH2wAOEl5uadSRANHhSppWEJDVCEN8mSdmBySYmiAhueLOgK wjqFjE/14NdMczA4EXZOF9CUhnGxkNHlh2N6Jj8jWPxaAmhs9gerVTGdv6KAbBE4dnZ9 Gt/6HwAQCiGk2eefh5BZnz5aLqHlTmW9XSUDgAl9dt4uvS5ZVLLpVPB4u2bWHaOaMYpf FoQVImsUDwt2S2quTEoMEGzkSVWX9Fono5g3brXN7vOVWCkJeAjCuQnKitAERkl9IBbD jmPVTyScjZKtgo9tB/FhJPGTPOcZYERD6WFMcgs5iIlbjbHys0CZkkEi4+9XPtell2bR krHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=xfe46Bmt0854EQhFRugeAp0o8UPMhV6L1Gu8vX/QvIg=; b=n7jkIFwux/GSY+MOrqap73Bz3QTU9X36ZhvVLGQWlFChjpx12qtwPJdxnRykfz4YE+ 3VrF6FahudgbzUIXT1KHy/BCV/oT+GyqdNXgU37JnHli5NYuuY21FJ4aX4KWpyQJGs6a x3/72wt1qswLg8kEj5Ol8lgnSjGuXVIdHLAPOsrAXnm7O62rfG/eMbc82YP5P6ytW8Dy 6xmAVG1CHvmQHC0nnFHVTmP948RrfOU1McTkw8jF8EbFA8UQAZSGWtk+ABIuPHjYlznp nFCr8SPZ5Dlp3JKAs2M4naqwGA2vleZivvMxt2RwKK4ooBj0duAypvf4JZb7btZa5QPq m0DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="c9l3U/2d"; 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 h68-v6si19277640pfb.142.2018.11.12.06.12.56; Mon, 12 Nov 2018 06:12:57 -0800 (PST) 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="c9l3U/2d"; 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 S1729426AbeKMAGW (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:22 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:39205 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbeKMAGW (ORCPT ); Mon, 12 Nov 2018 19:06:22 -0500 Received: by mail-lf1-f65.google.com with SMTP id n18so6274095lfh.6 for ; Mon, 12 Nov 2018 06:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xfe46Bmt0854EQhFRugeAp0o8UPMhV6L1Gu8vX/QvIg=; b=c9l3U/2dQOsUCgj8BbxfoO1yESceLkvc6v7qoWiFGZKRwjtsgfnrmk6jvclVFFuZSr Swr0+CzCXCHP2a1JnHgjuJuXS6MRUg2LTt1uE1Nwkgw1vNYkvby/x02nJx0Sbij/snjj 0Ry+ITxsc7Uu12MB6uLPLpkGImMr0wvLzde1s= 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:in-reply-to :references; bh=xfe46Bmt0854EQhFRugeAp0o8UPMhV6L1Gu8vX/QvIg=; b=dpDlF8MYnZbN4dZH0CEUj/hmPBOjViC+SFIAu5nnenFz5dwoblADnYRSFBX0NM1vzs reEBJjGNYSVG2keDy71s8RhW90ZEL0i91kt79h8EuWI+K6wkRfH2JzPwkbk3sHgngKda fKnjOcE9IiQB7e9XdC0JMLedyYWg+CLymHpj7mHB1wJwFLdhjoeaBOaOH9q/Ptqe8RvA 287s6EDjb9JGDx5aSywZJDaGYmEATzTshuYI+cH5Z6kNmPejeYAIcuTfXNaQfu+G5qU0 rOF48DPEkw5oeiIERgfc+wjnOdTtgu8gagKEbrEoTF7EBdUMkqYuKjLee2kuqdoOiLcq aiTg== X-Gm-Message-State: AGRZ1gI+3YX2k4A6K1kzVdemtsm+Ks5VEFKprgUTHaMPJvPJc22qeWvq BMqBcTsMmbSvhPJWyfzI9BCylo4euwCsIQ== X-Received: by 2002:a19:d9d6:: with SMTP id s83mr741245lfi.57.1542031973074; Mon, 12 Nov 2018 06:12:53 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.12.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:12:52 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Paul Cercueil , linux-mips@linux-mips.org Subject: [PATCH 02/10] mmc: jz4740: Get CD/WP GPIOs from descriptors Date: Mon, 12 Nov 2018 15:12:31 +0100 Message-Id: <20181112141239.19646-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Modifty the JZ4740 driver to retrieve card detect and write protect GPIO pins from GPIO descriptors instead of hard-coded global numbers. Augment the only board file using this in the process and cut down on passed in platform data. Preserve the code setting the caps2 flags for CD and WP as active low or high since the slot GPIO code currently ignores the gpiolib polarity inversion semantice and uses the raw accessors to read the GPIO lines, but set the right polarity flags in the descriptor table for jz4740. Cc: Paul Cercueil Cc: linux-mips@linux-mips.org Signed-off-by: Linus Walleij --- .../mips/include/asm/mach-jz4740/jz4740_mmc.h | 2 -- arch/mips/jz4740/board-qi_lb60.c | 12 ++++++++--- drivers/mmc/host/jz4740_mmc.c | 20 +++++++++---------- 3 files changed, 19 insertions(+), 15 deletions(-) -- 2.17.2 Acked-by: Paul Burton diff --git a/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h b/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h index e9cc62cfac99..ff50aeb1a933 100644 --- a/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h +++ b/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h @@ -4,8 +4,6 @@ struct jz4740_mmc_platform_data { int gpio_power; - int gpio_card_detect; - int gpio_read_only; unsigned card_detect_active_low:1; unsigned read_only_active_low:1; unsigned power_active_low:1; diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c index af0c8ace0141..705593d40d12 100644 --- a/arch/mips/jz4740/board-qi_lb60.c +++ b/arch/mips/jz4740/board-qi_lb60.c @@ -43,7 +43,6 @@ #include "clock.h" /* GPIOs */ -#define QI_LB60_GPIO_SD_CD JZ_GPIO_PORTD(0) #define QI_LB60_GPIO_SD_VCC_EN_N JZ_GPIO_PORTD(2) #define QI_LB60_GPIO_KEYOUT(x) (JZ_GPIO_PORTC(10) + (x)) @@ -386,12 +385,18 @@ static struct platform_device qi_lb60_gpio_keys = { }; static struct jz4740_mmc_platform_data qi_lb60_mmc_pdata = { - .gpio_card_detect = QI_LB60_GPIO_SD_CD, - .gpio_read_only = -1, .gpio_power = QI_LB60_GPIO_SD_VCC_EN_N, .power_active_low = 1, }; +static struct gpiod_lookup_table qi_lb60_mmc_gpio_table = { + .dev_id = "jz4740-mmc.0", + .table = { + GPIO_LOOKUP("GPIOD", 0, "cd", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* beeper */ static struct pwm_lookup qi_lb60_pwm_lookup[] = { PWM_LOOKUP("jz4740-pwm", 4, "pwm-beeper", NULL, 0, @@ -500,6 +505,7 @@ static int __init qi_lb60_init_platform_devices(void) gpiod_add_lookup_table(&qi_lb60_audio_gpio_table); gpiod_add_lookup_table(&qi_lb60_nand_gpio_table); gpiod_add_lookup_table(&qi_lb60_spigpio_gpio_table); + gpiod_add_lookup_table(&qi_lb60_mmc_gpio_table); spi_register_board_info(qi_lb60_spi_board_info, ARRAY_SIZE(qi_lb60_spi_board_info)); diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c index 0c1efd5100b7..44ea452add8e 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -983,17 +983,17 @@ static int jz4740_mmc_request_gpios(struct mmc_host *mmc, if (!pdata->read_only_active_low) mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; - if (gpio_is_valid(pdata->gpio_card_detect)) { - ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect, 0); - if (ret) - return ret; - } + /* + * Get optional card detect and write protect GPIOs, + * only back out on probe deferral. + */ + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); + if (ret == -EPROBE_DEFER) + return ret; - if (gpio_is_valid(pdata->gpio_read_only)) { - ret = mmc_gpio_request_ro(mmc, pdata->gpio_read_only); - if (ret) - return ret; - } + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL); + if (ret == -EPROBE_DEFER) + return ret; return jz4740_mmc_request_gpio(&pdev->dev, pdata->gpio_power, "MMC read only", true, pdata->power_active_low); From patchwork Mon Nov 12 14:12:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150841 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3190898ljp; Mon, 12 Nov 2018 06:12:59 -0800 (PST) X-Google-Smtp-Source: AJdET5f3kHPE/cEapXX9GPRFUSoVJBafvn9HRwIXlDSlpzJfml62Wb2T3ycfvZCgfjoQSxFiLEXV X-Received: by 2002:a63:2586:: with SMTP id l128mr997955pgl.104.1542031979526; Mon, 12 Nov 2018 06:12:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031979; cv=none; d=google.com; s=arc-20160816; b=jVRNqDKlxy7OvVJOGR5WCynGHQDlz8t6yOtd1nAE0on6XY1t3GRLRNOBQuUuPfsOAy ygU5HPOpoj24y4F11Pdtk3+p9xlGp+VhBTcNTUmTY6IngcdkiYFB6Xc5y+nOwkcaCJ5w lbRbPHYMdqU4IOTfFdshh2pFglJGXMvfZSNqiF0Cd7V72Vk6WQBEYVGyPG04QytHkbsm qCN1uQTaddJw+cac+0WhSRtqWib5z1pY7S3jZA4OSHdJXw5s7Jj0Rv2VC8erUuzUZAXe kWEPQgylpTubZ4gaKfL7w/vPPHglKt5brGHTa7vty8iOHL+wM/qlnbNH3O3nl7qpLASp XSHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=uyjO+El3MvuzjjZ225bk+ZX6NPv73zT4TF8rtrL6ozw=; b=zW1OJKlviXho2p9JOSnIiMjhQar+1iTQJmNnd5f+1eE/eCkM3sXYSVQAWpOiBV0FHm u/wyGNlZTeMJQSFCl4/HP82B0YMLL+SnnkqSl95hw9IIqPZyDxVI+p1yZasFENTz7Z19 mJc5GCPu3D9ba6jwitqBQ9RZjY8mUwIbqOG2WoOqr/+C+O7y5wBPm0CGClwp9NecDLSY 8/pl0MvwU8+kT/hhlaq5AdTPa5wPUIuvVxjVIudmU+M6qDH/NE+V8ar252/4rQUieAxT /WZoRfd3PWi3DxPuoAjeEVaGyrwNyzFpbZdKjdlu3DBQRW7tRaf1RMVhasH0d8lI8hXf Yypg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E7ULJOoS; 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 h68-v6si19277640pfb.142.2018.11.12.06.12.59; Mon, 12 Nov 2018 06:12:59 -0800 (PST) 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=E7ULJOoS; 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 S1729756AbeKMAGZ (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:25 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45195 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbeKMAGZ (ORCPT ); Mon, 12 Nov 2018 19:06:25 -0500 Received: by mail-lf1-f68.google.com with SMTP id b20so6248397lfa.12 for ; Mon, 12 Nov 2018 06:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uyjO+El3MvuzjjZ225bk+ZX6NPv73zT4TF8rtrL6ozw=; b=E7ULJOoS9VqJCsh8FXBvOvv6E7+kbFqeTbqHByoKAkGkqrJizrPlqkBTn34JG6j2e/ fa98zG0kg6oxLmOP9wEa5LOoX24nz++pnDqAQaRIKKi6WzHqgy17qGYPvf9tvUIPqUbC BhFVf1QZv51XGD5UR17Nvz00qyQKWQQ5iUZKY= 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:in-reply-to :references; bh=uyjO+El3MvuzjjZ225bk+ZX6NPv73zT4TF8rtrL6ozw=; b=WBWL69OPd0wSmBMapsPwxGvFon5ZUGZxGbu3nEE2HPe+5d9SbDPDvGZHtzcjCMi7tD G3uDMePCRPJ56RJ7Ck0MZGOmeY0j8Qahow2PMmzNPO376cGqC4pN5O6oJkmUa/x98OMu qf51+DkSra0qvCGqSD0bbZs/XYKffT04Uq1KHVHC4Ez2PmerSjOByvR+w/yzRvcEmb5p lkrVFR3+B6ZifcsLzDOPNqsUz5YUaYXVq6ymNAqKDRfMh/RqsYg3RH73wF5W7Uy/I/Kk BujhYariU6e7rl0C0kyM21ONpF97ghAFVb9UeYsuE740/Hzlr9EmPe1z6HeUq9MbZnXI k28A== X-Gm-Message-State: AGRZ1gK74iW9N0JJVFG019SUwgELj/s+yeu7kafqpuXWqQrVSwAobtx2 4Vfmf/HWuNbaKBB6dQbbYtwRwMXtfg45xQ== X-Received: by 2002:a19:c4cc:: with SMTP id u195mr687899lff.141.1542031975042; Mon, 12 Nov 2018 06:12:55 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.12.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:12:54 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Paul Cercueil , linux-mips@linux-mips.org Subject: [PATCH 03/10] mmc: jz4740: Use GPIO descriptor for power Date: Mon, 12 Nov 2018 15:12:32 +0100 Message-Id: <20181112141239.19646-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The power GPIO line is passed with inversion flags and all from the platform data. Switch to using an optional GPIO descriptor and use this to switch the power. Augment the only boardfile to pass in the proper "power" descriptor in the GPIO descriptor machine table instead. As the GPIO handling is now much simpler, we can cut down on some overhead code. Cc: Paul Cercueil Cc: linux-mips@linux-mips.org Signed-off-by: Linus Walleij --- .../mips/include/asm/mach-jz4740/jz4740_mmc.h | 2 - arch/mips/jz4740/board-qi_lb60.c | 6 +- drivers/mmc/host/jz4740_mmc.c | 65 +++++-------------- 3 files changed, 18 insertions(+), 55 deletions(-) -- 2.17.2 Acked-by: Paul Burton diff --git a/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h b/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h index ff50aeb1a933..9a7de47c7c79 100644 --- a/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h +++ b/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h @@ -3,10 +3,8 @@ #define __LINUX_MMC_JZ4740_MMC struct jz4740_mmc_platform_data { - int gpio_power; unsigned card_detect_active_low:1; unsigned read_only_active_low:1; - unsigned power_active_low:1; unsigned data_1bit:1; }; diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c index 705593d40d12..6718efb400f4 100644 --- a/arch/mips/jz4740/board-qi_lb60.c +++ b/arch/mips/jz4740/board-qi_lb60.c @@ -43,8 +43,6 @@ #include "clock.h" /* GPIOs */ -#define QI_LB60_GPIO_SD_VCC_EN_N JZ_GPIO_PORTD(2) - #define QI_LB60_GPIO_KEYOUT(x) (JZ_GPIO_PORTC(10) + (x)) #define QI_LB60_GPIO_KEYIN(x) (JZ_GPIO_PORTD(18) + (x)) #define QI_LB60_GPIO_KEYIN8 JZ_GPIO_PORTD(26) @@ -385,14 +383,14 @@ static struct platform_device qi_lb60_gpio_keys = { }; static struct jz4740_mmc_platform_data qi_lb60_mmc_pdata = { - .gpio_power = QI_LB60_GPIO_SD_VCC_EN_N, - .power_active_low = 1, + /* Intentionally left blank */ }; static struct gpiod_lookup_table qi_lb60_mmc_gpio_table = { .dev_id = "jz4740-mmc.0", .table = { GPIO_LOOKUP("GPIOD", 0, "cd", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("GPIOD", 2, "power", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c index 44ea452add8e..6f7a99e54af0 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -136,6 +136,7 @@ struct jz4740_mmc_host { struct platform_device *pdev; struct jz4740_mmc_platform_data *pdata; struct clk *clk; + struct gpio_desc *power; enum jz4740_mmc_version version; @@ -903,18 +904,16 @@ static void jz4740_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) switch (ios->power_mode) { case MMC_POWER_UP: jz4740_mmc_reset(host); - if (host->pdata && gpio_is_valid(host->pdata->gpio_power)) - gpio_set_value(host->pdata->gpio_power, - !host->pdata->power_active_low); + if (host->power) + gpiod_set_value(host->power, 1); host->cmdat |= JZ_MMC_CMDAT_INIT; clk_prepare_enable(host->clk); break; case MMC_POWER_ON: break; default: - if (host->pdata && gpio_is_valid(host->pdata->gpio_power)) - gpio_set_value(host->pdata->gpio_power, - host->pdata->power_active_low); + if (host->power) + gpiod_set_value(host->power, 0); clk_disable_unprepare(host->clk); break; } @@ -947,30 +946,9 @@ static const struct mmc_host_ops jz4740_mmc_ops = { .enable_sdio_irq = jz4740_mmc_enable_sdio_irq, }; -static int jz4740_mmc_request_gpio(struct device *dev, int gpio, - const char *name, bool output, int value) -{ - int ret; - - if (!gpio_is_valid(gpio)) - return 0; - - ret = gpio_request(gpio, name); - if (ret) { - dev_err(dev, "Failed to request %s gpio: %d\n", name, ret); - return ret; - } - - if (output) - gpio_direction_output(gpio, value); - else - gpio_direction_input(gpio); - - return 0; -} - -static int jz4740_mmc_request_gpios(struct mmc_host *mmc, - struct platform_device *pdev) +static int jz4740_mmc_request_gpios(struct jz4740_mmc_host *host, + struct mmc_host *mmc, + struct platform_device *pdev) { struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev); int ret = 0; @@ -995,19 +973,12 @@ static int jz4740_mmc_request_gpios(struct mmc_host *mmc, if (ret == -EPROBE_DEFER) return ret; - return jz4740_mmc_request_gpio(&pdev->dev, pdata->gpio_power, - "MMC read only", true, pdata->power_active_low); -} - -static void jz4740_mmc_free_gpios(struct platform_device *pdev) -{ - struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev); - - if (!pdata) - return; + host->power = devm_gpiod_get_optional(&pdev->dev, "power", + GPIOD_OUT_HIGH); + if (IS_ERR(host->power)) + return PTR_ERR(host->power); - if (gpio_is_valid(pdata->gpio_power)) - gpio_free(pdata->gpio_power); + return 0; } static const struct of_device_id jz4740_mmc_of_match[] = { @@ -1053,7 +1024,7 @@ static int jz4740_mmc_probe(struct platform_device* pdev) mmc->caps |= MMC_CAP_SDIO_IRQ; if (!(pdata && pdata->data_1bit)) mmc->caps |= MMC_CAP_4_BIT_DATA; - ret = jz4740_mmc_request_gpios(mmc, pdev); + ret = jz4740_mmc_request_gpios(host, mmc, pdev); if (ret) goto err_free_host; } @@ -1104,7 +1075,7 @@ static int jz4740_mmc_probe(struct platform_device* pdev) dev_name(&pdev->dev), host); if (ret) { dev_err(&pdev->dev, "Failed to request irq: %d\n", ret); - goto err_free_gpios; + goto err_free_host; } jz4740_mmc_clock_disable(host); @@ -1135,8 +1106,6 @@ static int jz4740_mmc_probe(struct platform_device* pdev) jz4740_mmc_release_dma_channels(host); err_free_irq: free_irq(host->irq, host); -err_free_gpios: - jz4740_mmc_free_gpios(pdev); err_free_host: mmc_free_host(mmc); @@ -1155,8 +1124,6 @@ static int jz4740_mmc_remove(struct platform_device *pdev) free_irq(host->irq, host); - jz4740_mmc_free_gpios(pdev); - if (host->use_dma) jz4740_mmc_release_dma_channels(host); From patchwork Mon Nov 12 14:12:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150842 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3190927ljp; Mon, 12 Nov 2018 06:13:01 -0800 (PST) X-Google-Smtp-Source: AJdET5ebVc9x6TG97Ekb0/1fYW40mWiU8N8ksylp9kW+LGLJQC7Qxe3rP9RQsWUHQN33RWTP6n+J X-Received: by 2002:a63:2586:: with SMTP id l128mr998077pgl.104.1542031981414; Mon, 12 Nov 2018 06:13:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031981; cv=none; d=google.com; s=arc-20160816; b=s/S8WvIpO2kytUTA3raxiu/SPxBvfAnh6QlziDMV+RuOiqoazCtcGzXPd6D4Hv/9zy JMhjxTdDldUhpgugtD4GcgJIBevxJn/Zo5olrtpVvCMCWQOp504fidEe4VWiM+K3nf/f 0/KIhw3Gu7Zhlf7iZ8+AN0pXDknwmH7qmQlFRkSBuB8sExSNfi2XSLTOhOF0CNhfoDS/ 8i8H7J8msFUkVFZWWhz1LibFvbmPxkqK1+pTI80uzeiuZag+K6j7wTxPYJmkbHnDdY3x JZl8oxpqkz+xqWAEM++Xivl/OqLWMO5ZxL+h+x00pPqFMDUukQ+pczdVXMXu6ZqIwABb JBDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=7y3jD4/WNZvvawkGnEbDQFXytTGvZIIkgomvEMbvkRk=; b=zBszrb/gwvrzSfmiLCtHrtFskpxSg8XNmVy/fPFst+8SxDrlEzmTSo0RjFFHHaD0fK oXf+48ER3e8cqFJndhzY8DHJs1X4TAq2ysgWIcTijdFlOq/tYxoqz2qr8E8a8UCS6d/R qYLFzvFJModNLU91nUKQW9AsDSg/pqTt599sq9lvKkXIjsxjM9SL/GA5JzH8JZgnVZWz xxsnqvxtmavTSLwzer2HxT+RScVR/pzR/tpD0gZtLgd7iakAKv0NMOEBG+X0B3zrvAmV tZ7fBo6LMmUhM8yFiaeBieXpQ5ZGF07PhF/ZI3AW0Tf048/pYmx4bc/lfUQ4vJF9cWtg sxqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ebaCHx7m; 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 h68-v6si19277640pfb.142.2018.11.12.06.13.00; Mon, 12 Nov 2018 06:13:01 -0800 (PST) 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=ebaCHx7m; 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 S1729766AbeKMAG0 (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:26 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41935 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729649AbeKMAG0 (ORCPT ); Mon, 12 Nov 2018 19:06:26 -0500 Received: by mail-lj1-f194.google.com with SMTP id z80-v6so7731673ljb.8 for ; Mon, 12 Nov 2018 06:12:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7y3jD4/WNZvvawkGnEbDQFXytTGvZIIkgomvEMbvkRk=; b=ebaCHx7m/GK5GUc1Pglj4fhpx1riPuhm4sERQmOwVEEbn9PMnVXJRkKT2vdKSHkNzz KTVE0dq92fqBy8WHbQa93MGk+vW2PmC4js27xMrekH8NdhGwuSs7UnNs4NEIXCnXgQJg +08VN210+xIm7i9XNaTGmGozgPWZRNR8iLZoU= 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:in-reply-to :references; bh=7y3jD4/WNZvvawkGnEbDQFXytTGvZIIkgomvEMbvkRk=; b=Wf0CH1+BojaGfRf9X4XIOkc4v6pOsoSMoBIZfmiYbDuEDBTBelG518m+NVvG0Gdn/a 0Tyn7128X9Q6Ud29wrFCqBV0xKcpJ+qgO2IhJSK2qmVl7kWCEqxULo065w7aQ8d5bolp u2OU7Z1scYQYgAkhAATPK8RX5mnvdVn+rkfDRHFFpvbWp9XcwTBTOi3l09OMzME8JPNf cgd4+7sKFqPoz9szYUVzuVmGrKQHosIy+IxKFf+QZGggaG8sCZB8bC8juwGjLBRlfBJy Lex4WNDOy8V+T0o9TbeOq2RljqGvCMKUCiZ+ABpOXnlW5KVzsEOTiDpP11Dl4QFiukyj QfIw== X-Gm-Message-State: AGRZ1gLbCvuVz/lg4CajQJxFh9meoRRnXxiWWZPbxtrx9BZ2+98oE9Uc DwaiBD/QP7BieDYqXhgT/l6Qy1yWDZSu6A== X-Received: by 2002:a2e:9b84:: with SMTP id z4-v6mr766259lji.93.1542031976746; Mon, 12 Nov 2018 06:12:56 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.12.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:12:55 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Hartley Sweeten , Kuninori Morimoto , Laurent Pinchart Subject: [PATCH 04/10] mmc: spi: Convert to use GPIO descriptors Date: Mon, 12 Nov 2018 15:12:33 +0100 Message-Id: <20181112141239.19646-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Switch the SPI MMC driver to use GPIO descriptors internally and just look those up using the standard slot GPIO functions mmc_gpiod_request_cd() and mmc_gpiod_request_ro(). Make sure to request index 0 and 1 in accordance with the SPI MMC DT binding, and add the same GPIOs in machine descriptor tables on all boards that use SPI MMC in board files. The lines are flagged as GPIO_ACTIVE_[LOW|HIGH] as that is what they are, but this will be ignored by the MMC slot GPIO code that uses the *raw accessors and rely on the caps2 flags MMC_CAP2_CD_ACTIVE_HIGH and MMC_CAP2_RO_ACTIVE_HIGH for polarity inversion semantics as of now. Cc: Hartley Sweeten # Vision EP9307 Cc: Kuninori Morimoto Cc: Laurent Pinchart Signed-off-by: Linus Walleij --- Hartley: it'd be great if you could test this series on the Vision EP9307. Kuninori/Laurent: hope one of you has this Ecovec board so you can test it too. --- arch/arm/mach-ep93xx/simone.c | 14 +++++++++--- arch/arm/mach-ep93xx/vision_ep9307.c | 17 ++++++++++---- arch/sh/boards/mach-ecovec24/setup.c | 17 +++++++++++--- drivers/mmc/host/mmc_spi.c | 27 ++++++++++++---------- drivers/mmc/host/of_mmc_spi.c | 34 ---------------------------- include/linux/spi/mmc_spi.h | 15 ------------ 6 files changed, 53 insertions(+), 71 deletions(-) -- 2.17.2 diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c index 41aa57581356..80ccb984d521 100644 --- a/arch/arm/mach-ep93xx/simone.c +++ b/arch/arm/mach-ep93xx/simone.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -45,9 +46,15 @@ static struct ep93xxfb_mach_info __initdata simone_fb_info = { static struct mmc_spi_platform_data simone_mmc_spi_data = { .detect_delay = 500, .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .flags = MMC_SPI_USE_CD_GPIO, - .cd_gpio = EP93XX_GPIO_LINE_EGPIO0, - .cd_debounce = 1, +}; + +static struct gpiod_lookup_table simone_mmc_spi_gpio_table = { + .dev_id = "mmc_spi.0", /* "mmc_spi" @ CS0 */ + .table = { + /* Card detect */ + GPIO_LOOKUP_IDX("A", 0, NULL, 0, GPIO_ACTIVE_LOW), + { }, + }, }; static struct spi_board_info simone_spi_devices[] __initdata = { @@ -105,6 +112,7 @@ static void __init simone_init_machine(void) ep93xx_register_fb(&simone_fb_info); ep93xx_register_i2c(simone_i2c_board_info, ARRAY_SIZE(simone_i2c_board_info)); + gpiod_add_lookup_table(&simone_mmc_spi_gpio_table); ep93xx_register_spi(&simone_spi_info, simone_spi_devices, ARRAY_SIZE(simone_spi_devices)); simone_register_audio(); diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c b/arch/arm/mach-ep93xx/vision_ep9307.c index 5a0b6187990a..767ee64628dc 100644 --- a/arch/arm/mach-ep93xx/vision_ep9307.c +++ b/arch/arm/mach-ep93xx/vision_ep9307.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -202,13 +203,20 @@ static struct mmc_spi_platform_data vision_spi_mmc_data = { .detect_delay = 100, .powerup_msecs = 100, .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO, - .cd_gpio = EP93XX_GPIO_LINE_EGPIO15, - .cd_debounce = 1, - .ro_gpio = EP93XX_GPIO_LINE_F(0), .caps2 = MMC_CAP2_RO_ACTIVE_HIGH, }; +static struct gpiod_lookup_table vision_spi_mmc_gpio_table = { + .dev_id = "mmc_spi.2", /* "mmc_spi @ CS2 */ + .table = { + /* Card detect */ + GPIO_LOOKUP_IDX("B", 7, NULL, 0, GPIO_ACTIVE_LOW), + /* Write protect */ + GPIO_LOOKUP_IDX("F", 0, NULL, 1, GPIO_ACTIVE_HIGH), + { }, + }, +}; + /************************************************************************* * SPI Bus *************************************************************************/ @@ -286,6 +294,7 @@ static void __init vision_init_machine(void) ep93xx_register_i2c(vision_i2c_info, ARRAY_SIZE(vision_i2c_info)); + gpiod_add_lookup_table(&vision_spi_mmc_gpio_table); ep93xx_register_spi(&vision_spi_master, vision_spi_board_info, ARRAY_SIZE(vision_spi_board_info)); vision_register_i2s(); diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index 06a894526a0b..3097307b7cb7 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -776,9 +776,19 @@ static struct mmc_spi_platform_data mmc_spi_info = { .caps2 = MMC_CAP2_RO_ACTIVE_HIGH, .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */ .setpower = mmc_spi_setpower, - .flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO, - .cd_gpio = GPIO_PTY7, - .ro_gpio = GPIO_PTY6, +}; + +static struct gpiod_lookup_table mmc_spi_gpio_table = { + .dev_id = "mmc_spi.0", /* device "mmc_spi" @ CS0 */ + .table = { + /* Card detect */ + GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY7, NULL, 0, + GPIO_ACTIVE_LOW), + /* Write protect */ + GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY6, NULL, 1, + GPIO_ACTIVE_HIGH), + { }, + }, }; static struct spi_board_info spi_bus[] = { @@ -1282,6 +1292,7 @@ static int __init arch_setup(void) gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */ gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */ + gpiod_add_lookup_table(&mmc_spi_gpio_table); spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); #endif diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 476e53d30128..10ba46b728e8 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -1434,13 +1434,16 @@ static int mmc_spi_probe(struct spi_device *spi) if (status != 0) goto fail_add_host; - if (host->pdata && host->pdata->flags & MMC_SPI_USE_CD_GPIO) { - status = mmc_gpio_request_cd(mmc, host->pdata->cd_gpio, - host->pdata->cd_debounce); - if (status != 0) - goto fail_add_host; - - /* The platform has a CD GPIO signal that may support + /* + * Index 0 is card detect + * Old boardfiles were specifying 1 ms as debounce + */ + status = mmc_gpiod_request_cd(mmc, NULL, 0, false, 1, NULL); + if (status == -EPROBE_DEFER) + goto fail_add_host; + if (!status) { + /* + * The platform has a CD GPIO signal that may support * interrupts, so let mmc_gpiod_request_cd_irq() decide * if polling is needed or not. */ @@ -1448,12 +1451,12 @@ static int mmc_spi_probe(struct spi_device *spi) mmc_gpiod_request_cd_irq(mmc); } - if (host->pdata && host->pdata->flags & MMC_SPI_USE_RO_GPIO) { + /* Index 1 is write protect/read only */ + status = mmc_gpiod_request_ro(mmc, NULL, 1, false, 0, NULL); + if (status == -EPROBE_DEFER) + goto fail_add_host; + if (!status) has_ro = true; - status = mmc_gpio_request_ro(mmc, host->pdata->ro_gpio); - if (status != 0) - goto fail_add_host; - } dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n", dev_name(&mmc->class_dev), diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c index c9eed8436b6b..b294b221f225 100644 --- a/drivers/mmc/host/of_mmc_spi.c +++ b/drivers/mmc/host/of_mmc_spi.c @@ -16,9 +16,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -32,15 +30,7 @@ MODULE_LICENSE("GPL"); -enum { - CD_GPIO = 0, - WP_GPIO, - NUM_GPIOS, -}; - struct of_mmc_spi { - int gpios[NUM_GPIOS]; - bool alow_gpios[NUM_GPIOS]; int detect_irq; struct mmc_spi_platform_data pdata; }; @@ -102,30 +92,6 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) oms->pdata.ocr_mask |= mask; } - for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) { - enum of_gpio_flags gpio_flags; - - oms->gpios[i] = of_get_gpio_flags(np, i, &gpio_flags); - if (!gpio_is_valid(oms->gpios[i])) - continue; - - if (gpio_flags & OF_GPIO_ACTIVE_LOW) - oms->alow_gpios[i] = true; - } - - if (gpio_is_valid(oms->gpios[CD_GPIO])) { - oms->pdata.cd_gpio = oms->gpios[CD_GPIO]; - oms->pdata.flags |= MMC_SPI_USE_CD_GPIO; - if (!oms->alow_gpios[CD_GPIO]) - oms->pdata.caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; - } - if (gpio_is_valid(oms->gpios[WP_GPIO])) { - oms->pdata.ro_gpio = oms->gpios[WP_GPIO]; - oms->pdata.flags |= MMC_SPI_USE_RO_GPIO; - if (!oms->alow_gpios[WP_GPIO]) - oms->pdata.caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; - } - oms->detect_irq = irq_of_parse_and_map(np, 0); if (oms->detect_irq != 0) { oms->pdata.init = of_mmc_spi_init; diff --git a/include/linux/spi/mmc_spi.h b/include/linux/spi/mmc_spi.h index bfde741a543d..778ae8eb1f3e 100644 --- a/include/linux/spi/mmc_spi.h +++ b/include/linux/spi/mmc_spi.h @@ -8,11 +8,6 @@ struct device; struct mmc_host; -#define MMC_SPI_USE_CD_GPIO (1 << 0) -#define MMC_SPI_USE_RO_GPIO (1 << 1) -#define MMC_SPI_CD_GPIO_ACTIVE_LOW (1 << 2) -#define MMC_SPI_RO_GPIO_ACTIVE_LOW (1 << 3) - /* Put this in platform_data of a device being used to manage an MMC/SD * card slot. (Modeled after PXA mmc glue; see that for usage examples.) * @@ -27,16 +22,6 @@ struct mmc_spi_platform_data { void *); void (*exit)(struct device *, void *); - /* - * Card Detect and Read Only GPIOs. To enable debouncing on the card - * detect GPIO, set the cd_debounce to the debounce time in - * microseconds. - */ - unsigned int flags; - unsigned int cd_gpio; - unsigned int cd_debounce; - unsigned int ro_gpio; - /* Capabilities to pass into mmc core (e.g. MMC_CAP_NEEDS_POLL). */ unsigned long caps; unsigned long caps2; From patchwork Mon Nov 12 14:12:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150843 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3190958ljp; Mon, 12 Nov 2018 06:13:03 -0800 (PST) X-Google-Smtp-Source: AJdET5f+udu2xCU94cyOZHYdtUkTdMfQra9Dod9k+QREeaLfAESoQaX99FmV1y4JiaXl655dbkKD X-Received: by 2002:a63:1444:: with SMTP id 4mr979183pgu.430.1542031982871; Mon, 12 Nov 2018 06:13:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031982; cv=none; d=google.com; s=arc-20160816; b=hQ54KBn22Ej2KNUXsfXWttKzDdZaII6Ufrc21mu/dRVRge8NA3IZtqxD3rnLwmmFWa lGqf/yZrMoYdkeNl0QVbUXIfGMnInRmA1RPGPGc+PedimT7Cw3m7tL/lqWu21EhTER0r gOFrJ1lyep++zseHhCMqV+rdODb8EV40sye80cawoX7UVOM+BJu21tt9F4f5u6SHTSQh AaxhCG9USxfb7kBfKxm1jsj7nBkUErJCsYarGQpDFqv7o4Fj67fd5P5B2wC39o8EWeKC vlSF+VkLxBrpZ6AjGGu/AGML3MhwGjdPGVbDtxuA31ucOzBCmMpzz87k1kiw6/zT34nS gMmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=qkZwlfqSP1GOA5zKMvcQHayGFcaoX0T0U5rEkTSpe7o=; b=agHC9UHri+6WeL226KlYSGB22HSD8KM7UHbxAFfhVYp5IVq86ggEMHFLXwCwsB1hXu jkEvIgYW9M54tKQ0Pf4rxB6UhcrwQ7ncSufTswrFPlB7O2WYVXQY5hOFi/skSR3D+0Y8 sAFvykg9Kd0RPoGxKczAqz6WmqemzOawLIH2O/f4mzrhJ9TVFDH+ME6N9Sl6pwVIjEN/ CfZzb/z4VgWb+YCvyP36gb+KeZkqw/EFF1dPcxpzRW6CKw+j+BDPOqjJlRgc5nmL7kUY 04m5k+IUAI5xGLWC1Ykq925ziJOa781a0JbbRPCkhnyUjUzuCxxbwO3Sv3G/6srUzMc3 eBBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=It6XBGzN; 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 h68-v6si19277640pfb.142.2018.11.12.06.13.02; Mon, 12 Nov 2018 06:13:02 -0800 (PST) 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=It6XBGzN; 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 S1729770AbeKMAG2 (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:28 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43263 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbeKMAG2 (ORCPT ); Mon, 12 Nov 2018 19:06:28 -0500 Received: by mail-lf1-f65.google.com with SMTP id u18so6256656lff.10 for ; Mon, 12 Nov 2018 06:12:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qkZwlfqSP1GOA5zKMvcQHayGFcaoX0T0U5rEkTSpe7o=; b=It6XBGzNHUZFMuWZDUlZ6i9/kixzhOmKvbewst++2huRSA/9pFFde/sxb11VvoIiCC WpOXnGB+Ko9hHLIGND98jK8XsDqrNDJCUUbq1YY14YQlC2q8zWv8BznUFN0REDNPrhK/ 2UbvQwERyxYhx610mhR91uj7stp2jWMqS+xQI= 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:in-reply-to :references; bh=qkZwlfqSP1GOA5zKMvcQHayGFcaoX0T0U5rEkTSpe7o=; b=fdHPacCzd9qcDuQjM3MK1sQMGEIxvwrg37ZsJxgdnX64T8MYCdD+un1FRrd8+Z7/KY DhXl7Z6HV4btTFu0n8i43O81NPOJ88pvcYu6enOF6asfWS1BXRwbC/NQib4AMG4VK6Te bgPC6p589f6PSDDoY8S/6Lm14CO20HJdO49Jih7WPS4SZfW3KLi+sKyccwHeUK5J0Lw9 YZJI+mPKldIoPoS0rV7/u5Bm5mEbkficDmNUZjbwLailDekkUbuC2LLQH2QXOFvGjqgk sBX7kxC453kr6ceBsE+jQrRRsMg2QL/yhdvUxs/1DHCecheRh+pCM7sDHxxlLG5iUXvf EgeA== X-Gm-Message-State: AGRZ1gLJpTO9xIEe16rmeWJs3UNMTSuvRuAjXhx2nzQ/to+risF6uER9 qNhrdFi7yNlIEvrrFCUxdETZb68nEB+a9g== X-Received: by 2002:a19:9fcd:: with SMTP id i196mr724186lfe.82.1542031978598; Mon, 12 Nov 2018 06:12:58 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.12.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:12:57 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Kuninori Morimoto , Laurent Pinchart Subject: [PATCH 05/10] mmc: host: tmio: Use GPIO descriptors Date: Mon, 12 Nov 2018 15:12:34 +0100 Message-Id: <20181112141239.19646-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The TMIO MMC driver was passing global GPIO numbers around for card detect. It turns out only one single board in the kernel was actually making use of this feature so it is pretty easy to convert the driver to use only GPIO descriptors. The lines are flagged as GPIO_ACTIVE_LOW as that is what they are, but this will be ignored by the MMC slot GPIO code that uses the *raw accessors and rely on the caps2 flag for any inversion semantics. Cc: Kuninori Morimoto Cc: Laurent Pinchart Signed-off-by: Linus Walleij --- Kuninori/Laurent: any tests/ACKs appreciated. --- arch/sh/boards/mach-ecovec24/setup.c | 26 ++++++++++++++++++++++---- drivers/mmc/host/tmio_mmc_core.c | 12 +++++++----- include/linux/mfd/tmio.h | 9 ++------- 3 files changed, 31 insertions(+), 16 deletions(-) -- 2.17.2 diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index 3097307b7cb7..af2c28946319 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -696,13 +696,20 @@ static struct gpiod_lookup_table sdhi0_power_gpiod_table = { }, }; +static struct gpiod_lookup_table sdhi0_gpio_table = { + .dev_id = "sh_mobile_sdhi.0", + .table = { + /* Card detect */ + GPIO_LOOKUP("sh7724_pfc", GPIO_PTY7, "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct tmio_mmc_data sdhi0_info = { .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX, .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX, .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | MMC_CAP_NEEDS_POLL, - .flags = TMIO_MMC_USE_GPIO_CD, - .cd_gpio = GPIO_PTY7, }; static struct resource sdhi0_resources[] = { @@ -735,8 +742,15 @@ static struct tmio_mmc_data sdhi1_info = { .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI1_RX, .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | MMC_CAP_NEEDS_POLL, - .flags = TMIO_MMC_USE_GPIO_CD, - .cd_gpio = GPIO_PTW7, +}; + +static struct gpiod_lookup_table sdhi1_gpio_table = { + .dev_id = "sh_mobile_sdhi.1", + .table = { + /* Card detect */ + GPIO_LOOKUP("sh7724_pfc", GPIO_PTW7, "cd", GPIO_ACTIVE_LOW), + { }, + }, }; static struct resource sdhi1_resources[] = { @@ -1445,6 +1459,10 @@ static int __init arch_setup(void) gpiod_add_lookup_table(&cn12_power_gpiod_table); #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) gpiod_add_lookup_table(&sdhi0_power_gpiod_table); + gpiod_add_lookup_table(&sdhi0_gpio_table); +#endif +#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) + gpiod_add_lookup_table(&sdhi1_gpio_table); #endif return platform_add_devices(ecovec_devices, diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 8d64f6196f33..487b88dceff4 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1167,11 +1167,13 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) if (ret < 0) return ret; - if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { - ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0); - if (ret) - return ret; - } + /* + * Look for a card detect GPIO, if it fails with anything + * else than a probe deferral, just live without it. + */ + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); + if (ret == -EPROBE_DEFER) + return ret; mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; mmc->caps2 |= pdata->capabilities2; diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h index 1e70060c92ce..e2687a30e5a1 100644 --- a/include/linux/mfd/tmio.h +++ b/include/linux/mfd/tmio.h @@ -54,12 +54,8 @@ * idle before writing to some registers. */ #define TMIO_MMC_HAS_IDLE_WAIT BIT(4) -/* - * A GPIO is used for card hotplug detection. We need an extra flag for this, - * because 0 is a valid GPIO number too, and requiring users to specify - * cd_gpio < 0 to disable GPIO hotplug would break backwards compatibility. - */ -#define TMIO_MMC_USE_GPIO_CD BIT(5) + +/* BIT(5) is unused */ /* * Some controllers have CMD12 automatically @@ -104,7 +100,6 @@ struct tmio_mmc_data { unsigned long capabilities2; unsigned long flags; u32 ocr_mask; /* available voltages */ - unsigned int cd_gpio; int alignment_shift; dma_addr_t dma_rx_offset; unsigned int max_blk_count; From patchwork Mon Nov 12 14:12:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150844 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3191005ljp; Mon, 12 Nov 2018 06:13:04 -0800 (PST) X-Google-Smtp-Source: AJdET5d85Nan8z3jlyCKeOwqIcqe+iVhmyXjzTsCNMkHx9Fk75HwsplIGZQnLw7/n7H0/3irNL33 X-Received: by 2002:a65:594b:: with SMTP id g11-v6mr923285pgu.229.1542031984458; Mon, 12 Nov 2018 06:13:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031984; cv=none; d=google.com; s=arc-20160816; b=KoY8zPwVfwkqOjebL0bmrRqj0ud/l+5b4aqoJonAvs9q7gPWBK+AKMEmeQItViuQTN VErdoyYfW/oH5xIBFjwoRFmzC70i5ocQmwnvAiz8LLnJzlf1jdORzjMl8qVIUcfcwvvN mYHaat7L49F8ZEpn21VdSWe6H/WrY78HuvKYK/Jk3xaKoBsXr+Jp7fIIiHmN2pugeY+H ehEuT4sphhBWzAYBN9wW029vGgdA/qUjN2h1sTROOTGMMYTiFlzV+93+POrMEvLhmzwP fFr9JRCdNN/4pfgh3VstmUGjPZKBbhu8+EN8Snz4EAaufrA8j5aXPu4Kkh3LyTUjXqV3 cV6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tMawrxzeXIhQY4yuJKEZ15lPPltGf7Hdmj8XRWJ2oNc=; b=Q5I2mwlaWowwaW4p7j9ZWa1Y1gcG+b00/+KlFAudCK6zAh+LIesz144tllb/7DNgXs NH5afUY4vMdPAbtRtGsnX6WsYadK1IVjG5yMjfYEE5h0BIzDpb01ft8C5bGCeEqbOA0f tk0Ksc3E7J2skbWyLLuXlJrJRxy4apJe/gqkZse6wAnypSLRk6Aeha5d93SsQ6EFT6dx /CAhlgpyeN8LQpv5MxJQJblrp55ILi8yqEvHp6mv0lmXcTGoxWmkWJd2yEUfQ7JbjqXe eOdk1x6lA95iCoCKnaZtinualc6Ka1xjFvf6AR2BwuioHTi4IpkRe97jB/Hm62ameF1a g2Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eGVFEriy; 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 h68-v6si19277640pfb.142.2018.11.12.06.13.04; Mon, 12 Nov 2018 06:13:04 -0800 (PST) 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=eGVFEriy; 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 S1727103AbeKMAGa (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:30 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:42465 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729649AbeKMAG3 (ORCPT ); Mon, 12 Nov 2018 19:06:29 -0500 Received: by mail-lf1-f67.google.com with SMTP id l10so2652432lfh.9 for ; Mon, 12 Nov 2018 06:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tMawrxzeXIhQY4yuJKEZ15lPPltGf7Hdmj8XRWJ2oNc=; b=eGVFEriyWv2bwZgfSP6Q3/a5ffhzo6Fqbxkd++YSO4koSofLKgs2B774QujiOC+dxe 2HJ84vhJGcRtK9PvfNrjrmGrV+haO8WAp5G3xvdwWof5nDVC+IDeh/0wdv+HxKAnckgZ AnvsoOTsx0ibfzqDZZQ+RceI61ScnaKOx+cq0= 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:in-reply-to :references; bh=tMawrxzeXIhQY4yuJKEZ15lPPltGf7Hdmj8XRWJ2oNc=; b=DEM7mGKADGv+Q+M0HkryM4ZuvMf+ClRlaeO8F7GmKEYfLJSY9hLEV6Gn3zJ3MdrDvt K8A+YEc2v1J7PGAkZIoRlAYA8Z/Vf03RUUU8gJCYz73NrTIq6oq6+2SIHVMJiClHUKyD MG5xv43k5LOKPYolrCfWIVAQygRdyRbye45KvDEtE2rgzg+mTo3duEz1yuLH17XB3Xc5 4dHxhYS6XUouuG0sxnGfT5fBEKNybRK8iON0jwx8an0sLb80WPnthKSNMv5K+ggTLiXo H9twdDf02WOZCenlqI+Hk9rJJzlmPh6UOkFLPidVVeWb1E/JyqxuxOXSQAQTj3eDxyHo 54jQ== X-Gm-Message-State: AGRZ1gJ45YUwG7bNwVJuZczVAvj6FSHbNnQ7VvxMm64U3HlNrtPxJIv0 WrmkE+QjqMbjINFlLR3LRAJsgLsROY+gpg== X-Received: by 2002:a19:a7c1:: with SMTP id q184mr712928lfe.4.1542031980573; Mon, 12 Nov 2018 06:13:00 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.12.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:12:59 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Bartosz Golaszewski Subject: [PATCH 06/10] mmc: sdhci: imx: Use the slot GPIO descriptor Date: Mon, 12 Nov 2018 15:12:35 +0100 Message-Id: <20181112141239.19646-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Simplify things by making the i.MX SDHCI driver just use slot GPIO with descriptors instead of passing around the global GPIO numbers that we want to get rid of. As it turns out, just one single board is using the platform data to pass in GPIOs numbers for CD and WP, so we augment this to use a machine descriptor table instead. Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Cc: Bartosz Golaszewski Signed-off-by: Linus Walleij --- This very much needs to be tested on the PCM043. If it works fine, it also opens the way for switching more i.MX boardfiles to using machine GPIO descriptor tables. --- arch/arm/mach-imx/mach-pcm043.c | 17 +++++++++++++---- drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++------ include/linux/platform_data/mmc-esdhc-imx.h | 4 ---- 3 files changed, 21 insertions(+), 14 deletions(-) -- 2.17.2 Reviewed-by: Dong Aisheng diff --git a/arch/arm/mach-imx/mach-pcm043.c b/arch/arm/mach-imx/mach-pcm043.c index e595e5368676..46ba3348e8f0 100644 --- a/arch/arm/mach-imx/mach-pcm043.c +++ b/arch/arm/mach-imx/mach-pcm043.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -214,8 +215,6 @@ static const iomux_v3_cfg_t pcm043_pads[] __initconst = { #define AC97_GPIO_TXFS IMX_GPIO_NR(2, 31) #define AC97_GPIO_TXD IMX_GPIO_NR(2, 28) #define AC97_GPIO_RESET IMX_GPIO_NR(2, 0) -#define SD1_GPIO_WP IMX_GPIO_NR(2, 23) -#define SD1_GPIO_CD IMX_GPIO_NR(2, 24) static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97) { @@ -341,12 +340,21 @@ static int __init pcm043_otg_mode(char *options) __setup("otg_mode=", pcm043_otg_mode); static struct esdhc_platform_data sd1_pdata = { - .wp_gpio = SD1_GPIO_WP, - .cd_gpio = SD1_GPIO_CD, .wp_type = ESDHC_WP_GPIO, .cd_type = ESDHC_CD_GPIO, }; +static struct gpiod_lookup_table sd1_gpio_table = { + .dev_id = "sdhci-esdhc-imx35.0", + .table = { + /* Card detect: bank 2 offset 24 */ + GPIO_LOOKUP("imx35-gpio.2", 24, "cd", GPIO_ACTIVE_LOW), + /* Write protect: bank 2 offset 23 */ + GPIO_LOOKUP("imx35-gpio.2", 23, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + /* * Board specific initialization. */ @@ -391,6 +399,7 @@ static void __init pcm043_late_init(void) { imx35_add_imx_ssi(0, &pcm043_ssi_pdata); + gpiod_add_lookup_table(&sd1_gpio_table); imx35_add_sdhci_esdhc_imx(0, &sd1_pdata); } diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index f44e49014a44..982d2a9866dc 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -21,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -1139,8 +1137,12 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, if (of_get_property(np, "fsl,wp-controller", NULL)) boarddata->wp_type = ESDHC_WP_CONTROLLER; - boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0); - if (gpio_is_valid(boarddata->wp_gpio)) + /* + * If we have this property, then activate WP check. + * Retrieveing and requesting the actual WP GPIO will happen + * in the call to mmc_of_parse(). + */ + if (of_property_read_bool(np, "wp-gpios")) boarddata->wp_type = ESDHC_WP_GPIO; of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step); @@ -1198,7 +1200,7 @@ static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev, host->mmc->parent->platform_data); /* write_protect */ if (boarddata->wp_type == ESDHC_WP_GPIO) { - err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio); + err = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL); if (err) { dev_err(mmc_dev(host->mmc), "failed to request write-protect gpio!\n"); @@ -1210,7 +1212,7 @@ static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev, /* card_detect */ switch (boarddata->cd_type) { case ESDHC_CD_GPIO: - err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0); + err = mmc_gpiod_request_cd(host->mmc, "cd", 0, false, 0, NULL); if (err) { dev_err(mmc_dev(host->mmc), "failed to request card-detect gpio!\n"); diff --git a/include/linux/platform_data/mmc-esdhc-imx.h b/include/linux/platform_data/mmc-esdhc-imx.h index 640dec8b5b0c..b606ca4197df 100644 --- a/include/linux/platform_data/mmc-esdhc-imx.h +++ b/include/linux/platform_data/mmc-esdhc-imx.h @@ -30,15 +30,11 @@ enum cd_types { * * ESDHC_WP(CD)_CONTROLLER type is not available on i.MX25/35. * - * @wp_gpio: gpio for write_protect - * @cd_gpio: gpio for card_detect interrupt * @wp_type: type of write_protect method (see wp_types enum above) * @cd_type: type of card_detect method (see cd_types enum above) */ struct esdhc_platform_data { - unsigned int wp_gpio; - unsigned int cd_gpio; enum wp_types wp_type; enum cd_types cd_type; int max_bus_width; From patchwork Mon Nov 12 14:12:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150845 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3191050ljp; Mon, 12 Nov 2018 06:13:06 -0800 (PST) X-Google-Smtp-Source: AJdET5eaXF2XHHUHFJdew8Md/Wi1dr6mgfGF0YnfEd/BXE/FcDIGLqPUEw82KMsTzPK2oqcWPe7g X-Received: by 2002:a17:902:7685:: with SMTP id m5-v6mr893184pll.111.1542031985956; Mon, 12 Nov 2018 06:13:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031985; cv=none; d=google.com; s=arc-20160816; b=CnV0h0OgWer5V7P5FyvA5GM0dxxVvyKOcpl/tumpyNIq3y5WaA/BwWmzK7teMxulus CWB64vqtc4xA2ghVumqqy7HkxICPBP8CyxV6YSLmiUVls+37NuVpBHB3yRalhRggZy/9 WxYKD90dRgXLTQIrCcRU0zBpgnjya1NFSr+E5262mIo0JYHZzv2I1PaWdQECXMHL3zSY zWiPgBatcAv1naHyJDvBOtqVVXs+Qt5j/yBFi+NJ3Abo/5pS5xAtcdr9hcIrL6E8Vetx VIMqb7urmZXTj4AhgHz+KBkHcI1HuudB/KM3qzyniGHvfEAx7K6L93Pwtpsw+guTiqtO 0RZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=cseakbWMfrOIIxEXUOkkGdJsVqnFECKv4E7As0pNwTQ=; b=WQC5Oogo5qtOq3nANIfVpdF4VW2eSkfymsruf4eDY9Xdp8bSlJplk4r6ayoOHvbTDy 3txadCKERbqmPQGQJcPGORc2TcNq2d+l51ZbNeUIWCC7vzIcEcglBYvU5d/GEFHAXByy 0s9gUKFii7Kn1UiUZCb490f0Ub4v6S5r+qmr3MrQNPg5kEwYz3LMTVngD+HJ9bCGI5/1 dn3eVRxnSMfourNxR+E01IXswZsMeQusxIJB/W3mLbhEKLwZksufs+k8Aa20K8zkZcYH M9ImWphL8tye8Ctmvg9ZBHbCYa1RNMzwSSnBHnuCYMcrP03KyczKu9sm61vUugSj4pDy 88Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GHEl/1ZD"; 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 h68-v6si19277640pfb.142.2018.11.12.06.13.05; Mon, 12 Nov 2018 06:13:05 -0800 (PST) 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="GHEl/1ZD"; 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 S1729649AbeKMAGb (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:31 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37432 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbeKMAGb (ORCPT ); Mon, 12 Nov 2018 19:06:31 -0500 Received: by mail-lf1-f65.google.com with SMTP id p17so6286780lfh.4 for ; Mon, 12 Nov 2018 06:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cseakbWMfrOIIxEXUOkkGdJsVqnFECKv4E7As0pNwTQ=; b=GHEl/1ZDljW3kJ6neqdbgdBn3m4ZNVmM80KFiCcnTlQHyhzVaG9ui6MfHl7q0CEMth DyE68D6a/msF0b/68DfOJ/IEvnipS3CRwqRvEB3jFQ88DQDZiFJtH33g3P17+WTbNdsV 9nSIqRw9w4ZhuBYU4PathGuMQtxw4OpyXVk2s= 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:in-reply-to :references; bh=cseakbWMfrOIIxEXUOkkGdJsVqnFECKv4E7As0pNwTQ=; b=GHR0OV8iBG27M69v+LscRq21u1kaDMZE3n/oI64naBHb+wDsIJ0sReWM+8cG7Z58Q3 oKmTHQqFBxBq5Tg4sAPsyr5v/jEpBr1xAEoWX8bNfs3wE54k5XNGewXGe2zu7wwWLc4T a9yyevWB01ZjouVtM+IwA7qSKgtZGmoYtH1KOnvSNmpTfDdOG2LYc3V1baVEyiPsRlS1 q8kcpelTyTkLcAKEGBrDaYHs301WTl3AScG6QiZCd/dL4BWNPo7Z5XMdMJiQpHtG++8I e/tE4rPVB7E5VVE8w8PRTzU1y7jqFwfduyYrFvI31Q73GQ6GxhzBtYr8K4TiO508dlhl 9z/Q== X-Gm-Message-State: AGRZ1gK6SJJXV6IPircvWrpMIe1oTmUre+XPVDLXeIa+ZH68c5SWoD1a f5wxCfCgDd17BdfstJ1n28oOIcthUblrcA== X-Received: by 2002:a19:5d42:: with SMTP id p2mr741328lfj.83.1542031982575; Mon, 12 Nov 2018 06:13:02 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.13.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:13:01 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Jaehoon Chung , Sylwester Nawrocki , Krzysztof Kozlowski , Sergio Prado Subject: [PATCH 07/10] mmc: s3cmci: Use the slot GPIO descriptor Date: Mon, 12 Nov 2018 15:12:36 +0100 Message-Id: <20181112141239.19646-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Simplify things by making the S3CMCI driver just use slot GPIO with descriptors instead of passing around the global GPIO numbers that we want to get rid of. Getting the names of the GPIO chips into the machine descriptor tables was a bit of a challenge but I think I have them right. The platform data supports passing in inversion flags, but no platform is using them, and it is highly unlikely that we will add more, so drop them. The long term plan is to let the inversion flags on the GPIO machine descriptor do the job. Even if the slot GPIO core discards the inversion semantics on the GPIO lines we take special care to specify them right. Cc: Jaehoon Chung Cc: Sylwester Nawrocki Cc: Krzysztof Kozlowski Cc: Sergio Prado Signed-off-by: Linus Walleij --- Some testing of this would be greatly appreciated. --- arch/arm/mach-s3c24xx/mach-at2440evb.c | 14 +++++++++-- arch/arm/mach-s3c24xx/mach-h1940.c | 15 +++++++++-- arch/arm/mach-s3c24xx/mach-mini2440.c | 16 +++++++++--- arch/arm/mach-s3c24xx/mach-n30.c | 15 +++++++++-- arch/arm/mach-s3c24xx/mach-rx1950.c | 15 +++++++++-- drivers/mmc/host/s3cmci.c | 32 ++++++++---------------- include/linux/platform_data/mmc-s3cmci.h | 4 --- 7 files changed, 75 insertions(+), 36 deletions(-) -- 2.17.2 diff --git a/arch/arm/mach-s3c24xx/mach-at2440evb.c b/arch/arm/mach-s3c24xx/mach-at2440evb.c index 68a4fa94257a..2d370f7f75fa 100644 --- a/arch/arm/mach-s3c24xx/mach-at2440evb.c +++ b/arch/arm/mach-s3c24xx/mach-at2440evb.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -136,7 +136,16 @@ static struct platform_device at2440evb_device_eth = { }; static struct s3c24xx_mci_pdata at2440evb_mci_pdata __initdata = { - .gpio_detect = S3C2410_GPG(10), + /* Intentionally left blank */ +}; + +static struct gpiod_lookup_table at2440evb_mci_gpio_table = { + .dev_id = "s3c2410-sdi", + .table = { + /* Card detect S3C2410_GPG(10) */ + GPIO_LOOKUP("GPIOG", 10, "cd", GPIO_ACTIVE_LOW), + { }, + }, }; /* 7" LCD panel */ @@ -200,6 +209,7 @@ static void __init at2440evb_init_time(void) static void __init at2440evb_init(void) { s3c24xx_fb_set_platdata(&at2440evb_fb_info); + gpiod_add_lookup_table(&at2440evb_mci_gpio_table); s3c24xx_mci_set_platdata(&at2440evb_mci_pdata); s3c_nand_set_platdata(&at2440evb_nand_info); s3c_i2c0_set_platdata(NULL); diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c index e064c73a57d3..8d9d8e7c71d4 100644 --- a/arch/arm/mach-s3c24xx/mach-h1940.c +++ b/arch/arm/mach-s3c24xx/mach-h1940.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -459,12 +460,21 @@ static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd) } static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = { - .gpio_detect = S3C2410_GPF(5), - .gpio_wprotect = S3C2410_GPH(8), .set_power = h1940_set_mmc_power, .ocr_avail = MMC_VDD_32_33, }; +static struct gpiod_lookup_table h1940_mmc_gpio_table = { + .dev_id = "s3c2410-sdi", + .table = { + /* Card detect S3C2410_GPF(5) */ + GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW), + /* Write protect S3C2410_GPH(8) */ + GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct pwm_lookup h1940_pwm_lookup[] = { PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 36296, PWM_POLARITY_NORMAL), @@ -680,6 +690,7 @@ static void __init h1940_init(void) u32 tmp; s3c24xx_fb_set_platdata(&h1940_fb_info); + gpiod_add_lookup_table(&h1940_mmc_gpio_table); s3c24xx_mci_set_platdata(&h1940_mmc_cfg); s3c24xx_udc_set_platdata(&h1940_udc_cfg); s3c24xx_ts_set_platdata(&h1940_ts_cfg); diff --git a/arch/arm/mach-s3c24xx/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c index 50d67d760efd..8c5f222126d2 100644 --- a/arch/arm/mach-s3c24xx/mach-mini2440.c +++ b/arch/arm/mach-s3c24xx/mach-mini2440.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -234,13 +235,21 @@ static struct s3c2410fb_mach_info mini2440_fb_info __initdata = { /* MMC/SD */ static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = { - .gpio_detect = S3C2410_GPG(8), - .gpio_wprotect = S3C2410_GPH(8), - .wprotect_invert = 1, .set_power = NULL, .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34, }; +static struct gpiod_lookup_table mini2440_mmc_gpio_table = { + .dev_id = "s3c2410-sdi", + .table = { + /* Card detect S3C2410_GPG(8) */ + GPIO_LOOKUP("GPIOG", 8, "cd", GPIO_ACTIVE_LOW), + /* Write protect S3C2410_GPH(8) */ + GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + /* NAND Flash on MINI2440 board */ static struct mtd_partition mini2440_default_nand_part[] __initdata = { @@ -696,6 +705,7 @@ static void __init mini2440_init(void) } s3c24xx_udc_set_platdata(&mini2440_udc_cfg); + gpiod_add_lookup_table(&mini2440_mmc_gpio_table); s3c24xx_mci_set_platdata(&mini2440_mmc_cfg); s3c_nand_set_platdata(&mini2440_nand_info); s3c_i2c0_set_platdata(NULL); diff --git a/arch/arm/mach-s3c24xx/mach-n30.c b/arch/arm/mach-s3c24xx/mach-n30.c index eec51fadb14a..ffa20f52aa83 100644 --- a/arch/arm/mach-s3c24xx/mach-n30.c +++ b/arch/arm/mach-s3c24xx/mach-n30.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -350,12 +351,21 @@ static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd) } static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = { - .gpio_detect = S3C2410_GPF(1), - .gpio_wprotect = S3C2410_GPG(10), .ocr_avail = MMC_VDD_32_33, .set_power = n30_sdi_set_power, }; +static struct gpiod_lookup_table n30_mci_gpio_table = { + .dev_id = "s3c2410-sdi", + .table = { + /* Card detect S3C2410_GPF(1) */ + GPIO_LOOKUP("GPIOF", 1, "cd", GPIO_ACTIVE_LOW), + /* Write protect S3C2410_GPG(10) */ + GPIO_LOOKUP("GPIOG", 10, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct platform_device *n30_devices[] __initdata = { &s3c_device_lcd, &s3c_device_wdt, @@ -549,6 +559,7 @@ static void __init n30_init(void) s3c24xx_fb_set_platdata(&n30_fb_info); s3c24xx_udc_set_platdata(&n30_udc_cfg); + gpiod_add_lookup_table(&n30_mci_gpio_table); s3c24xx_mci_set_platdata(&n30_mci_cfg); s3c_i2c0_set_platdata(&n30_i2ccfg); diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c index 7f5a18fa305b..534e9c1d8161 100644 --- a/arch/arm/mach-s3c24xx/mach-rx1950.c +++ b/arch/arm/mach-s3c24xx/mach-rx1950.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -558,12 +559,21 @@ static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd) } static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = { - .gpio_detect = S3C2410_GPF(5), - .gpio_wprotect = S3C2410_GPH(8), .set_power = rx1950_set_mmc_power, .ocr_avail = MMC_VDD_32_33, }; +static struct gpiod_lookup_table rx1950_mmc_gpio_table = { + .dev_id = "s3c2410-sdi", + .table = { + /* Card detect S3C2410_GPF(5) */ + GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW), + /* Write protect S3C2410_GPH(8) */ + GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct mtd_partition rx1950_nand_part[] = { [0] = { .name = "Boot0", @@ -762,6 +772,7 @@ static void __init rx1950_init_machine(void) s3c24xx_fb_set_platdata(&rx1950_lcd_cfg); s3c24xx_udc_set_platdata(&rx1950_udc_cfg); s3c24xx_ts_set_platdata(&rx1950_ts_cfg); + gpiod_add_lookup_table(&rx1950_mmc_gpio_table); s3c24xx_mci_set_platdata(&rx1950_mmc_cfg); s3c_i2c0_set_platdata(NULL); s3c_nand_set_platdata(&rx1950_nand_info); diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index f77493604312..529b48d66d43 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -1542,28 +1541,19 @@ static int s3cmci_probe_pdata(struct s3cmci_host *host) if (pdata->no_detect) mmc->caps |= MMC_CAP_NEEDS_POLL; - if (pdata->wprotect_invert) - mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; - - if (pdata->detect_invert) - mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; - - if (gpio_is_valid(pdata->gpio_detect)) { - ret = mmc_gpio_request_cd(mmc, pdata->gpio_detect, 0); - if (ret) { - dev_err(&pdev->dev, "error requesting GPIO for CD %d\n", - ret); - return ret; - } + /* If we get -ENOENT we have no card detect GPIO line */ + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); + if (ret != -ENOENT) { + dev_err(&pdev->dev, "error requesting GPIO for CD %d\n", + ret); + return ret; } - if (gpio_is_valid(pdata->gpio_wprotect)) { - ret = mmc_gpio_request_ro(mmc, pdata->gpio_wprotect); - if (ret) { - dev_err(&pdev->dev, "error requesting GPIO for WP %d\n", - ret); - return ret; - } + ret = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL); + if (ret != -ENOENT) { + dev_err(&pdev->dev, "error requesting GPIO for WP %d\n", + ret); + return ret; } return 0; diff --git a/include/linux/platform_data/mmc-s3cmci.h b/include/linux/platform_data/mmc-s3cmci.h index b68d9f0bdd9e..87274a267fe4 100644 --- a/include/linux/platform_data/mmc-s3cmci.h +++ b/include/linux/platform_data/mmc-s3cmci.h @@ -30,12 +30,8 @@ struct s3c24xx_mci_pdata { unsigned int no_wprotect:1; unsigned int no_detect:1; - unsigned int wprotect_invert:1; - unsigned int detect_invert:1; /* set => detect active high */ unsigned int use_dma:1; - unsigned int gpio_detect; - unsigned int gpio_wprotect; unsigned long ocr_avail; void (*set_power)(unsigned char power_mode, unsigned short vdd); From patchwork Mon Nov 12 14:12:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150847 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3191191ljp; Mon, 12 Nov 2018 06:13:12 -0800 (PST) X-Google-Smtp-Source: AJdET5eMJhU6zmUI4ciKN8QFslk1AxPcRoTAAqtGsAdNStzVIKNzkrgfVPZhHifhTDedSgrq5mSl X-Received: by 2002:a63:1444:: with SMTP id 4mr979777pgu.430.1542031992680; Mon, 12 Nov 2018 06:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031992; cv=none; d=google.com; s=arc-20160816; b=i1ovYAhAF31UztGvEqMAXaGPM4G74eOtUq/ghkUKYpU47g0JfZT9kvXvHCgmuV44rx 7sIhft51RFhx4YVK17l1aGrJAZ6eQHjWgBQwdIJE5iRQ9O0HyTU0Z+NBYVZTU/DBMlYB E5M395JXF/awB26lvZCurpXYvCbkABh1SoRlcusg9u9yk8AP5A2t3LmyCvD0Sdh0zTkF ilG+mwpBMRL2tSlXq7beUyCjbxAaLjtKlU8T8DBoqFDi+x4Tml7rHNg41QBJ2SETPqdo XeZEcDamDy45ZOtIGYiagiSNQ9MFyuAdBywQIsDu0h6lm1GvRmJctXciTXEqRK+9+Dny qg/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=j+EoqAvZAoHdgfqmrTUScWhR/1RVZ/MwutuYGzPawZ0=; b=gGc64LnAJgVY3DwEl23lQqQWukxbYTdUXo3W17r6nxWFjPU85EP5h2V3oY60OGwdGk pBFr9WzBHmKxyQLUsvqHQDti6su94HpKQ1VafmEiHnbpagdUAEOXyY2/87e812Zibu2y ITETeE/hzoZGDvYbGnXmC5qh8GqjddJtW/Z/RcFa5+/OUn1GPlls+5mMkrMmUJ4c4hk/ RS5auf0iJRiL3zNIBwWjT0W9hDeXEiYfJpnHPoOK8aw7WCdbMEdQpA/zABJmO6bZtGVW b9cvztobv+ZYaqBFsc+1q00nFL1k2WTpG7yN4r+xct36Zy+zKNK+odcG0P9BRzss3efk 3ZKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZnGQN9Pp; 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 h68-v6si19277640pfb.142.2018.11.12.06.13.12; Mon, 12 Nov 2018 06:13:12 -0800 (PST) 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=ZnGQN9Pp; 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 S1729803AbeKMAGi (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:38 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:42473 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbeKMAGi (ORCPT ); Mon, 12 Nov 2018 19:06:38 -0500 Received: by mail-lf1-f67.google.com with SMTP id l10so2652630lfh.9 for ; Mon, 12 Nov 2018 06:13:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j+EoqAvZAoHdgfqmrTUScWhR/1RVZ/MwutuYGzPawZ0=; b=ZnGQN9PpdhFfV3SeoRKgcpxfP4oEgg+yP9fsvw8iBVWSK1GSdFulvOE54a/Phb2+WG ob0lYrNVmevybsdBx2N6GNQO+WgawIAH+Lt/fZoXxHCDTiwTxIGNlHHMDTh3iMJQOkyf omVvmkmXwkedYl/uUZkg15yVPqO5WpiZiALxU= 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:in-reply-to :references; bh=j+EoqAvZAoHdgfqmrTUScWhR/1RVZ/MwutuYGzPawZ0=; b=Vt+W+XDJMfrVSSGRgR3cPtq5h0qJL0NhVqyfgxyx4xMnAyHpIPjJ7oqhFdlIfgyN2/ g4+MY2KmqTTEb1NyCk3d8gZd0/luJdnRU5MqgpCwWPXapBvqiGuu1bwm7eqcIFLmV5RT 2IXGriR/yhZRWP5Qn/XAqc/Lbvo/ApEKZ5g1c18tM04jlxtrqng2OUu7syqw7GI4N1YG sFrUnZlF4iXkXuecQGlyf3XOQo3WHbkKNbXqEIqRh1X7O/yc/m+M1wRVcbnVv26/VDhg kDhcHfWeJrkyzX8d2H5XrUjTGp1PnNW4dxTV7Bhj9tEW5R9qkEXoNnLpwvw1xoKMbt58 RVug== X-Gm-Message-State: AGRZ1gJ6PJQ7CWJTelIStwmMclhorbcOD+bV7IvQLtehSPagnEPq87w1 AInZD4nHtD9Wa/nhZIdyWN+A0esEHnGHxw== X-Received: by 2002:a19:9a8c:: with SMTP id c134mr693630lfe.152.1542031984866; Mon, 12 Nov 2018 06:13:04 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.13.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:13:03 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Daniel Mack , Robert Jarzmik , Bartosz Golaszewski , Andrea Adami Subject: [PATCH 08/10] mmc: pxa: Use the slot GPIO descriptor Date: Mon, 12 Nov 2018 15:12:37 +0100 Message-Id: <20181112141239.19646-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Simplify things by making the PXA MCI driver just use slot GPIO with descriptors instead of passing around the global GPIO numbers that we want to get rid of. This involves augmenting more or less every PXA boardfile, associating each card detect or write protect line with the right GPIO chip or GPIO expander. As we are no longer checking for global GPIO numbers we avoid having to fill them in at all in the platform data including the kludge of setting the GPIO to -1 when we don't have either signal. We just look for the slot GPIO descriptor for CD and WP and if we find it we use it. We take care of correctly specifying the edge sensitivity of the GPIO lines (active low or active high) so we can later on use this flag even though the MMC slot GPIO code uses the *raw accessors and rely on the caps2 flags MMC_CAP2_CD_ACTIVE_HIGH and MMC_CAP2_RO_ACTIVE_HIGH for polarity inversion semantics as of now. Cc: Daniel Mack Cc: Robert Jarzmik Cc: Bartosz Golaszewski Cc: Andrea Adami Signed-off-by: Linus Walleij --- arch/arm/mach-pxa/balloon3.c | 2 -- arch/arm/mach-pxa/cm-x270.c | 18 ++++++---- arch/arm/mach-pxa/cm-x300.c | 21 +++++++----- arch/arm/mach-pxa/colibri-evalboard.c | 40 +++++++++++++++++----- arch/arm/mach-pxa/colibri-pxa270-income.c | 18 +++++++--- arch/arm/mach-pxa/corgi.c | 16 +++++++-- arch/arm/mach-pxa/csb726.c | 18 ++++++++-- arch/arm/mach-pxa/em-x270.c | 33 +++++++----------- arch/arm/mach-pxa/gumstix.c | 2 -- arch/arm/mach-pxa/idp.c | 2 -- arch/arm/mach-pxa/littleton.c | 16 ++++++--- arch/arm/mach-pxa/lubbock.c | 2 -- arch/arm/mach-pxa/magician.c | 15 +++++++-- arch/arm/mach-pxa/mainstone.c | 2 -- arch/arm/mach-pxa/mioa701.c | 15 +++++++-- arch/arm/mach-pxa/mxm8x10.c | 16 +++++++-- arch/arm/mach-pxa/palm27x.c | 8 ++--- arch/arm/mach-pxa/palm27x.h | 12 ++++--- arch/arm/mach-pxa/palmld.c | 15 +++++++-- arch/arm/mach-pxa/palmt5.c | 15 +++++++-- arch/arm/mach-pxa/palmtc.c | 16 +++++++-- arch/arm/mach-pxa/palmte2.c | 15 +++++++-- arch/arm/mach-pxa/palmtreo.c | 29 +++++++++++++--- arch/arm/mach-pxa/palmtx.c | 15 +++++++-- arch/arm/mach-pxa/palmz72.c | 15 +++++++-- arch/arm/mach-pxa/pcm990-baseboard.c | 2 -- arch/arm/mach-pxa/poodle.c | 14 ++++++-- arch/arm/mach-pxa/raumfeld.c | 2 -- arch/arm/mach-pxa/spitz.c | 15 +++++++-- arch/arm/mach-pxa/stargate2.c | 2 -- arch/arm/mach-pxa/tosa.c | 15 +++++++-- arch/arm/mach-pxa/trizeps4.c | 2 -- arch/arm/mach-pxa/vpac270.c | 15 +++++++-- arch/arm/mach-pxa/z2.c | 13 +++++-- arch/arm/mach-pxa/zeus.c | 14 ++++++-- arch/arm/mach-pxa/zylonite.c | 41 ++++++++++++++++++----- drivers/mmc/host/pxamci.c | 37 +++++++++----------- include/linux/platform_data/mmc-pxamci.h | 2 -- 38 files changed, 397 insertions(+), 153 deletions(-) -- 2.17.2 diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c index c52c081eb6d9..612109c515da 100644 --- a/arch/arm/mach-pxa/balloon3.c +++ b/arch/arm/mach-pxa/balloon3.c @@ -290,8 +290,6 @@ static unsigned long balloon3_mmc_pin_config[] __initdata = { static struct pxamci_platform_data balloon3_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, .detect_delay_ms = 200, }; diff --git a/arch/arm/mach-pxa/cm-x270.c b/arch/arm/mach-pxa/cm-x270.c index be4a66166d61..8c530fcd87d9 100644 --- a/arch/arm/mach-pxa/cm-x270.c +++ b/arch/arm/mach-pxa/cm-x270.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -30,11 +31,6 @@ /* physical address if local-bus attached devices */ #define RTC_PHYS_BASE (PXA_CS1_PHYS + (5 << 22)) -/* GPIO IRQ usage */ -#define GPIO83_MMC_IRQ (83) - -#define CMX270_MMC_IRQ PXA_GPIO_TO_IRQ(GPIO83_MMC_IRQ) - /* MMC power enable */ #define GPIO105_MMC_POWER (105) @@ -288,14 +284,22 @@ static inline void cmx270_init_ohci(void) {} #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) static struct pxamci_platform_data cmx270_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_card_detect = GPIO83_MMC_IRQ, - .gpio_card_ro = -1, .gpio_power = GPIO105_MMC_POWER, .gpio_power_invert = 1, }; +static struct gpiod_lookup_table cmx270_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Card detect on GPIO 83 */ + GPIO_LOOKUP("gpio-pxa", 83, "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init cmx270_init_mmc(void) { + gpiod_add_lookup_table(&cmx270_mci_gpio_table); pxa_set_mci_info(&cmx270_mci_platform_data); } #else diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c index c5c0ab8ac9f9..93a2d5b58f84 100644 --- a/arch/arm/mach-pxa/cm-x300.c +++ b/arch/arm/mach-pxa/cm-x300.c @@ -64,11 +64,6 @@ #define CM_X300_ETH_PHYS 0x08000010 -#define GPIO82_MMC_IRQ (82) -#define GPIO85_MMC_WP (85) - -#define CM_X300_MMC_IRQ PXA_GPIO_TO_IRQ(GPIO82_MMC_IRQ) - #define GPIO95_RTC_CS (95) #define GPIO96_RTC_WR (96) #define GPIO97_RTC_RD (97) @@ -459,11 +454,20 @@ static inline void cm_x300_init_nand(void) {} static struct pxamci_platform_data cm_x300_mci_platform_data = { .detect_delay_ms = 200, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_card_detect = GPIO82_MMC_IRQ, - .gpio_card_ro = GPIO85_MMC_WP, .gpio_power = -1, }; +static struct gpiod_lookup_table cm_x300_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Card detect on GPIO 82 */ + GPIO_LOOKUP("gpio-pxa", 82, "cd", GPIO_ACTIVE_LOW), + /* Write protect on GPIO 85 */ + GPIO_LOOKUP("gpio-pxa", 85, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + /* The second MMC slot of CM-X300 is hardwired to Libertas card and has no detection/ro pins */ static int cm_x300_mci2_init(struct device *dev, @@ -482,13 +486,12 @@ static struct pxamci_platform_data cm_x300_mci2_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .init = cm_x300_mci2_init, .exit = cm_x300_mci2_exit, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; static void __init cm_x300_init_mmc(void) { + gpiod_add_lookup_table(&cm_x300_mci_gpio_table); pxa_set_mci_info(&cm_x300_mci_platform_data); pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data); } diff --git a/arch/arm/mach-pxa/colibri-evalboard.c b/arch/arm/mach-pxa/colibri-evalboard.c index 10e2278b7a28..2ccdef5de138 100644 --- a/arch/arm/mach-pxa/colibri-evalboard.c +++ b/arch/arm/mach-pxa/colibri-evalboard.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -37,22 +37,44 @@ #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) static struct pxamci_platform_data colibri_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = -1, - .gpio_card_ro = -1, .detect_delay_ms = 200, }; +static struct gpiod_lookup_table colibri_pxa270_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO0_COLIBRI_PXA270_SD_DETECT, + "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + +static struct gpiod_lookup_table colibri_pxa300_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO13_COLIBRI_PXA300_SD_DETECT, + "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + +static struct gpiod_lookup_table colibri_pxa320_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO28_COLIBRI_PXA320_SD_DETECT, + "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init colibri_mmc_init(void) { if (machine_is_colibri()) /* PXA270 Colibri */ - colibri_mci_platform_data.gpio_card_detect = - GPIO0_COLIBRI_PXA270_SD_DETECT; + gpiod_add_lookup_table(&colibri_pxa270_mci_gpio_table); if (machine_is_colibri300()) /* PXA300 Colibri */ - colibri_mci_platform_data.gpio_card_detect = - GPIO13_COLIBRI_PXA300_SD_DETECT; + gpiod_add_lookup_table(&colibri_pxa300_mci_gpio_table); else /* PXA320 Colibri */ - colibri_mci_platform_data.gpio_card_detect = - GPIO28_COLIBRI_PXA320_SD_DETECT; + gpiod_add_lookup_table(&colibri_pxa320_mci_gpio_table); pxa_set_mci_info(&colibri_mci_platform_data); } diff --git a/arch/arm/mach-pxa/colibri-pxa270-income.c b/arch/arm/mach-pxa/colibri-pxa270-income.c index 3ccf2a95569b..3554e6befbb8 100644 --- a/arch/arm/mach-pxa/colibri-pxa270-income.c +++ b/arch/arm/mach-pxa/colibri-pxa270-income.c @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include @@ -39,8 +39,6 @@ #include "generic.h" #define GPIO114_INCOME_ETH_IRQ (114) -#define GPIO0_INCOME_SD_DETECT (0) -#define GPIO0_INCOME_SD_RO (1) #define GPIO54_INCOME_LED_A (54) #define GPIO55_INCOME_LED_B (55) #define GPIO113_INCOME_TS_IRQ (113) @@ -52,13 +50,23 @@ static struct pxamci_platform_data income_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, .gpio_power = -1, - .gpio_card_detect = GPIO0_INCOME_SD_DETECT, - .gpio_card_ro = GPIO0_INCOME_SD_RO, .detect_delay_ms = 200, }; +static struct gpiod_lookup_table income_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Card detect on GPIO 0 */ + GPIO_LOOKUP("gpio-pxa", 0, "cd", GPIO_ACTIVE_LOW), + /* Write protect on GPIO 1 */ + GPIO_LOOKUP("gpio-pxa", 1, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init income_mmc_init(void) { + gpiod_add_lookup_table(&income_mci_gpio_table); pxa_set_mci_info(&income_mci_platform_data); } #else diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index 9a5a35e90769..d57a3738a200 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -493,11 +494,21 @@ static struct platform_device corgi_audio_device = { static struct pxamci_platform_data corgi_mci_platform_data = { .detect_delay_ms = 250, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_card_detect = CORGI_GPIO_nSD_DETECT, - .gpio_card_ro = CORGI_GPIO_nSD_WP, .gpio_power = CORGI_GPIO_SD_PWR, }; +static struct gpiod_lookup_table corgi_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Card detect on GPIO 9 */ + GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_nSD_DETECT, + "cd", GPIO_ACTIVE_LOW), + /* Write protect on GPIO 7 */ + GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_nSD_WP, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; /* * Irda @@ -731,6 +742,7 @@ static void __init corgi_init(void) corgi_init_spi(); pxa_set_udc_info(&udc_info); + gpiod_add_lookup_table(&corgi_mci_gpio_table); pxa_set_mci_info(&corgi_mci_platform_data); pxa_set_ficp_info(&corgi_ficp_platform_data); pxa_set_i2c_info(NULL); diff --git a/arch/arm/mach-pxa/csb726.c b/arch/arm/mach-pxa/csb726.c index 271aedae7542..f00e0c12f63e 100644 --- a/arch/arm/mach-pxa/csb726.c +++ b/arch/arm/mach-pxa/csb726.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -129,11 +129,22 @@ static struct pxamci_platform_data csb726_mci = { .detect_delay_ms = 500, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, /* FIXME setpower */ - .gpio_card_detect = CSB726_GPIO_MMC_DETECT, - .gpio_card_ro = CSB726_GPIO_MMC_RO, .gpio_power = -1, }; +static struct gpiod_lookup_table csb726_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Card detect on GPIO 100 */ + GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_DETECT, + "cd", GPIO_ACTIVE_LOW), + /* Write protect on GPIO 101 */ + GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_RO, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct pxaohci_platform_data csb726_ohci_platform_data = { .port_mode = PMM_NPS_MODE, .flags = ENABLE_PORT1 | NO_OC_PROTECTION, @@ -264,6 +275,7 @@ static void __init csb726_init(void) pxa_set_stuart_info(NULL); pxa_set_i2c_info(NULL); pxa27x_set_i2c_power_info(NULL); + gpiod_add_lookup_table(&csb726_mci_gpio_table); pxa_set_mci_info(&csb726_mci); pxa_set_ohci_info(&csb726_ohci_platform_data); pxa_set_ac97_info(NULL); diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c index 67e37df637f5..e41d94e3c2c3 100644 --- a/arch/arm/mach-pxa/em-x270.c +++ b/arch/arm/mach-pxa/em-x270.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -546,6 +547,15 @@ static inline void em_x270_init_ohci(void) {} #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) static struct regulator *em_x270_sdio_ldo; +static struct gpiod_lookup_table em_x270_mci_wp_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Write protect on GPIO 95 */ + GPIO_LOOKUP("gpio-pxa", GPIO95_MMC_WP, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static int em_x270_mci_init(struct device *dev, irq_handler_t em_x270_detect_int, void *data) @@ -567,15 +577,7 @@ static int em_x270_mci_init(struct device *dev, goto err_irq; } - if (machine_is_em_x270()) { - err = gpio_request(GPIO95_MMC_WP, "MMC WP"); - if (err) { - dev_err(dev, "can't request MMC write protect: %d\n", - err); - goto err_gpio_wp; - } - gpio_direction_input(GPIO95_MMC_WP); - } else { + if (!machine_is_em_x270()) { err = gpio_request(GPIO38_SD_PWEN, "sdio power"); if (err) { dev_err(dev, "can't request MMC power control : %d\n", @@ -615,17 +617,10 @@ static void em_x270_mci_exit(struct device *dev, void *data) free_irq(gpio_to_irq(mmc_cd), data); regulator_put(em_x270_sdio_ldo); - if (machine_is_em_x270()) - gpio_free(GPIO95_MMC_WP); - else + if (!machine_is_em_x270()) gpio_free(GPIO38_SD_PWEN); } -static int em_x270_mci_get_ro(struct device *dev) -{ - return gpio_get_value(GPIO95_MMC_WP); -} - static struct pxamci_platform_data em_x270_mci_platform_data = { .detect_delay_ms = 250, .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23| @@ -635,15 +630,13 @@ static struct pxamci_platform_data em_x270_mci_platform_data = { .init = em_x270_mci_init, .setpower = em_x270_mci_setpower, .exit = em_x270_mci_exit, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; static void __init em_x270_init_mmc(void) { if (machine_is_em_x270()) - em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro; + gpiod_add_lookup_table(&em_x270_mci_wp_gpio_table); pxa_set_mci_info(&em_x270_mci_platform_data); } diff --git a/arch/arm/mach-pxa/gumstix.c b/arch/arm/mach-pxa/gumstix.c index 9c5b2fb054f9..fef80dc401de 100644 --- a/arch/arm/mach-pxa/gumstix.c +++ b/arch/arm/mach-pxa/gumstix.c @@ -90,8 +90,6 @@ static struct platform_device *devices[] __initdata = { #ifdef CONFIG_MMC_PXA static struct pxamci_platform_data gumstix_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c index 88e0068f92a8..a03b23c2fee9 100644 --- a/arch/arm/mach-pxa/idp.c +++ b/arch/arm/mach-pxa/idp.c @@ -160,8 +160,6 @@ static struct pxafb_mach_info sharp_lm8v31 = { static struct pxamci_platform_data idp_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; diff --git a/arch/arm/mach-pxa/littleton.c b/arch/arm/mach-pxa/littleton.c index 9e132b3e48c6..704a0effba3d 100644 --- a/arch/arm/mach-pxa/littleton.c +++ b/arch/arm/mach-pxa/littleton.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,8 +51,6 @@ #include "generic.h" -#define GPIO_MMC1_CARD_DETECT mfp_to_gpio(MFP_PIN_GPIO15) - /* Littleton MFP configurations */ static mfp_cfg_t littleton_mfp_cfg[] __initdata = { /* LCD */ @@ -278,13 +276,21 @@ static inline void littleton_init_keypad(void) {} static struct pxamci_platform_data littleton_mci_platform_data = { .detect_delay_ms = 200, .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_card_detect = GPIO_MMC1_CARD_DETECT, - .gpio_card_ro = -1, .gpio_power = -1, }; +static struct gpiod_lookup_table littleton_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Card detect on MFP (gpio-pxa) GPIO 15 */ + GPIO_LOOKUP("gpio-pxa", 15, "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init littleton_init_mmc(void) { + gpiod_add_lookup_table(&littleton_mci_gpio_table); pxa_set_mci_info(&littleton_mci_platform_data); } #else diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c index fe2ef9b78602..469cbc6b747f 100644 --- a/arch/arm/mach-pxa/lubbock.c +++ b/arch/arm/mach-pxa/lubbock.c @@ -440,8 +440,6 @@ static struct pxamci_platform_data lubbock_mci_platform_data = { .init = lubbock_mci_init, .get_ro = lubbock_mci_get_ro, .exit = lubbock_mci_exit, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index 14c0f80bc9e7..3e515394b20a 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -775,12 +775,22 @@ static struct pxamci_platform_data magician_mci_info = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .init = magician_mci_init, .exit = magician_mci_exit, - .gpio_card_detect = -1, - .gpio_card_ro = EGPIO_MAGICIAN_nSD_READONLY, .gpio_card_ro_invert = 1, .gpio_power = EGPIO_MAGICIAN_SD_POWER, }; +static struct gpiod_lookup_table magician_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* + * Write protect on EGPIO register 5 index 4, this is + * on the second HTC EGPIO chip which starts at regiser + * 4, so we need offset 8+4=12 on that particular chip. + */ + GPIO_LOOKUP("htc-egpio-1", 12, "wp", GPIO_ACTIVE_HIGH), + { }, + }, +}; /* * USB OHCI @@ -979,6 +989,7 @@ static void __init magician_init(void) i2c_register_board_info(1, ARRAY_AND_SIZE(magician_pwr_i2c_board_info)); + gpiod_add_lookup_table(&magician_mci_gpio_table); pxa_set_mci_info(&magician_mci_info); pxa_set_ohci_info(&magician_ohci_info); pxa_set_udc_info(&magician_udc_info); diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c index afd62a94fdbf..31142b17d845 100644 --- a/arch/arm/mach-pxa/mainstone.c +++ b/arch/arm/mach-pxa/mainstone.c @@ -361,8 +361,6 @@ static struct pxamci_platform_data mainstone_mci_platform_data = { .init = mainstone_mci_init, .setpower = mainstone_mci_setpower, .exit = mainstone_mci_exit, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c index 04dc78d0809f..d2941c256233 100644 --- a/arch/arm/mach-pxa/mioa701.c +++ b/arch/arm/mach-pxa/mioa701.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -397,11 +398,20 @@ struct gpio_vbus_mach_info gpio_vbus_data = { static struct pxamci_platform_data mioa701_mci_info = { .detect_delay_ms = 250, .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_card_detect = GPIO15_SDIO_INSERT, - .gpio_card_ro = GPIO78_SDIO_RO, .gpio_power = GPIO91_SDIO_EN, }; +static struct gpiod_lookup_table mioa701_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Card detect on GPIO 15 */ + GPIO_LOOKUP("gpio-pxa", 15, "cd", GPIO_ACTIVE_LOW), + /* Write protect on GPIO 78 */ + GPIO_LOOKUP("gpio-pxa", 78, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + /* FlashRAM */ static struct resource docg3_resource = { .start = PXA_CS0_PHYS, @@ -743,6 +753,7 @@ static void __init mioa701_machine_init(void) pr_err("MioA701: Failed to request GPIOs: %d", rc); bootstrap_init(); pxa_set_fb_info(NULL, &mioa701_pxafb_info); + gpiod_add_lookup_table(&mioa701_mci_gpio_table); pxa_set_mci_info(&mioa701_mci_info); pxa_set_keypad_info(&mioa701_keypad_info); pxa_set_udc_info(&mioa701_udc_info); diff --git a/arch/arm/mach-pxa/mxm8x10.c b/arch/arm/mach-pxa/mxm8x10.c index 616b22397d73..d1562e35644c 100644 --- a/arch/arm/mach-pxa/mxm8x10.c +++ b/arch/arm/mach-pxa/mxm8x10.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -326,13 +326,23 @@ static mfp_cfg_t mfp_cfg[] __initdata = { static struct pxamci_platform_data mxm_8x10_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, .detect_delay_ms = 10, - .gpio_card_detect = MXM_8X10_SD_nCD, - .gpio_card_ro = MXM_8X10_SD_WP, .gpio_power = -1 }; +static struct gpiod_lookup_table mxm_8x10_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + /* Card detect on GPIO 72 */ + GPIO_LOOKUP("gpio-pxa", 72, "cd", GPIO_ACTIVE_LOW), + /* Write protect on GPIO 84 */ + GPIO_LOOKUP("gpio-pxa", 84, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + void __init mxm_8x10_mmc_init(void) { + gpiod_add_lookup_table(&mxm_8x10_mci_gpio_table); pxa_set_mci_info(&mxm_8x10_mci_platform_data); } #endif diff --git a/arch/arm/mach-pxa/palm27x.c b/arch/arm/mach-pxa/palm27x.c index 1efe9bcf07fa..62b37fecfdcb 100644 --- a/arch/arm/mach-pxa/palm27x.c +++ b/arch/arm/mach-pxa/palm27x.c @@ -49,14 +49,14 @@ static struct pxamci_platform_data palm27x_mci_platform_data = { .detect_delay_ms = 200, }; -void __init palm27x_mmc_init(int detect, int ro, int power, - int power_inverted) +void __init palm27x_mmc_init(struct gpiod_lookup_table *gtable, int power, + int power_inverted) { - palm27x_mci_platform_data.gpio_card_detect = detect; - palm27x_mci_platform_data.gpio_card_ro = ro; palm27x_mci_platform_data.gpio_power = power; palm27x_mci_platform_data.gpio_power_invert = power_inverted; + if (gtable) + gpiod_add_lookup_table(gtable); pxa_set_mci_info(&palm27x_mci_platform_data); } #endif diff --git a/arch/arm/mach-pxa/palm27x.h b/arch/arm/mach-pxa/palm27x.h index d4eac3d6ffb5..05e3f04c11e2 100644 --- a/arch/arm/mach-pxa/palm27x.h +++ b/arch/arm/mach-pxa/palm27x.h @@ -12,12 +12,16 @@ #ifndef __INCLUDE_MACH_PALM27X__ #define __INCLUDE_MACH_PALM27X__ +#include + #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) -extern void __init palm27x_mmc_init(int detect, int ro, int power, - int power_inverted); +extern void __init palm27x_mmc_init(struct gpiod_lookup_table *gtable, + int power, + int power_inverted); #else -static inline void palm27x_mmc_init(int detect, int ro, int power, - int power_inverted) +static inline void palm27x_mmc_init(struct gpiod_lookup_table *gtable, + int power, + int power_inverted) {} #endif diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c index 980f2847f5b5..63d81c1a3103 100644 --- a/arch/arm/mach-pxa/palmld.c +++ b/arch/arm/mach-pxa/palmld.c @@ -320,6 +320,17 @@ static void __init palmld_map_io(void) iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc)); } +static struct gpiod_lookup_table palmld_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_READONLY, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init palmld_init(void) { pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config)); @@ -327,8 +338,8 @@ static void __init palmld_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); - palm27x_mmc_init(GPIO_NR_PALMLD_SD_DETECT_N, GPIO_NR_PALMLD_SD_READONLY, - GPIO_NR_PALMLD_SD_POWER, 0); + palm27x_mmc_init(&palmld_mci_gpio_table, + GPIO_NR_PALMLD_SD_POWER, 0); palm27x_pm_init(PALMLD_STR_BASE); palm27x_lcd_init(-1, &palm_320x480_lcd_mode); palm27x_irda_init(GPIO_NR_PALMLD_IR_DISABLE); diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c index 876144aa3564..81a37116081b 100644 --- a/arch/arm/mach-pxa/palmt5.c +++ b/arch/arm/mach-pxa/palmt5.c @@ -182,6 +182,17 @@ static void __init palmt5_reserve(void) memblock_reserve(0xa0200000, 0x1000); } +static struct gpiod_lookup_table palmt5_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_READONLY, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init palmt5_init(void) { pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config)); @@ -189,8 +200,8 @@ static void __init palmt5_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); - palm27x_mmc_init(GPIO_NR_PALMT5_SD_DETECT_N, GPIO_NR_PALMT5_SD_READONLY, - GPIO_NR_PALMT5_SD_POWER, 0); + palm27x_mmc_init(&palmt5_mci_gpio_table, + GPIO_NR_PALMT5_SD_POWER, 0); palm27x_pm_init(PALMT5_STR_BASE); palm27x_lcd_init(-1, &palm_320x480_lcd_mode); palm27x_udc_init(GPIO_NR_PALMT5_USB_DETECT_N, diff --git a/arch/arm/mach-pxa/palmtc.c b/arch/arm/mach-pxa/palmtc.c index 18946594a7c8..7b4c686de8c2 100644 --- a/arch/arm/mach-pxa/palmtc.c +++ b/arch/arm/mach-pxa/palmtc.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -121,13 +121,23 @@ static unsigned long palmtc_pin_config[] __initdata = { static struct pxamci_platform_data palmtc_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, .gpio_power = GPIO_NR_PALMTC_SD_POWER, - .gpio_card_ro = GPIO_NR_PALMTC_SD_READONLY, - .gpio_card_detect = GPIO_NR_PALMTC_SD_DETECT_N, .detect_delay_ms = 200, }; +static struct gpiod_lookup_table palmtc_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_READONLY, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init palmtc_mmc_init(void) { + gpiod_add_lookup_table(&palmtc_mci_gpio_table); pxa_set_mci_info(&palmtc_mci_platform_data); } #else diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c index 36b46141a28b..77cb2d98cbdd 100644 --- a/arch/arm/mach-pxa/palmte2.c +++ b/arch/arm/mach-pxa/palmte2.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -101,11 +102,20 @@ static unsigned long palmte2_pin_config[] __initdata = { ******************************************************************************/ static struct pxamci_platform_data palmte2_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N, - .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY, .gpio_power = GPIO_NR_PALMTE2_SD_POWER, }; +static struct gpiod_lookup_table palmte2_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_READONLY, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) /****************************************************************************** * GPIO keys @@ -354,6 +364,7 @@ static void __init palmte2_init(void) pxa_set_stuart_info(NULL); pxa_set_fb_info(NULL, &palmte2_lcd_screen); + gpiod_add_lookup_table(&palmte2_mci_gpio_table); pxa_set_mci_info(&palmte2_mci_platform_data); palmte2_udc_init(); pxa_set_ac97_info(&palmte2_ac97_pdata); diff --git a/arch/arm/mach-pxa/palmtreo.c b/arch/arm/mach-pxa/palmtreo.c index b66b0b11d717..ea44f699240f 100644 --- a/arch/arm/mach-pxa/palmtreo.c +++ b/arch/arm/mach-pxa/palmtreo.c @@ -480,23 +480,44 @@ void __init treo680_gpio_init(void) gpio_free(GPIO_NR_TREO680_LCD_EN_N); } +static struct gpiod_lookup_table treo680_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_READONLY, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init treo680_init(void) { pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config)); palmphone_common_init(); treo680_gpio_init(); - palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY, - GPIO_NR_TREO680_SD_POWER, 0); + palm27x_mmc_init(&treo680_mci_gpio_table, + GPIO_NR_TREO680_SD_POWER, 0); } #endif #ifdef CONFIG_MACH_CENTRO + +static struct gpiod_lookup_table centro685_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init centro_init(void) { pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config)); palmphone_common_init(); - palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, -1, - GPIO_NR_CENTRO_SD_POWER, 1); + palm27x_mmc_init(¢ro685_mci_gpio_table, + GPIO_NR_CENTRO_SD_POWER, 1); } #endif diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c index 1d06a8e91d8f..9df7cd84ba7b 100644 --- a/arch/arm/mach-pxa/palmtx.c +++ b/arch/arm/mach-pxa/palmtx.c @@ -337,6 +337,17 @@ static void __init palmtx_map_io(void) iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc)); } +static struct gpiod_lookup_table palmtx_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_READONLY, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init palmtx_init(void) { pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config)); @@ -344,8 +355,8 @@ static void __init palmtx_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); - palm27x_mmc_init(GPIO_NR_PALMTX_SD_DETECT_N, GPIO_NR_PALMTX_SD_READONLY, - GPIO_NR_PALMTX_SD_POWER, 0); + palm27x_mmc_init(&palmtx_mci_gpio_table, + GPIO_NR_PALMTX_SD_POWER, 0); palm27x_pm_init(PALMTX_STR_BASE); palm27x_lcd_init(-1, &palm_320x480_lcd_mode); palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N, diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c index 4d475f6f4a77..febf5aadbde6 100644 --- a/arch/arm/mach-pxa/palmz72.c +++ b/arch/arm/mach-pxa/palmz72.c @@ -386,6 +386,17 @@ static void __init palmz72_camera_init(void) static inline void palmz72_camera_init(void) {} #endif +static struct gpiod_lookup_table palmz72_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_RO, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + /****************************************************************************** * Machine init ******************************************************************************/ @@ -396,8 +407,8 @@ static void __init palmz72_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); - palm27x_mmc_init(GPIO_NR_PALMZ72_SD_DETECT_N, GPIO_NR_PALMZ72_SD_RO, - GPIO_NR_PALMZ72_SD_POWER_N, 1); + palm27x_mmc_init(&palmz72_mci_gpio_table, + GPIO_NR_PALMZ72_SD_POWER_N, 1); palm27x_lcd_init(-1, &palm_320x320_lcd_mode); palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N, GPIO_NR_PALMZ72_USB_PULLUP, 0); diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c index 973568d4b9ec..f76d7665420e 100644 --- a/arch/arm/mach-pxa/pcm990-baseboard.c +++ b/arch/arm/mach-pxa/pcm990-baseboard.c @@ -370,8 +370,6 @@ static struct pxamci_platform_data pcm990_mci_platform_data = { .init = pcm990_mci_init, .setpower = pcm990_mci_setpower, .exit = pcm990_mci_exit, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c index 1adde1251e2b..9b8663ac532f 100644 --- a/arch/arm/mach-pxa/poodle.c +++ b/arch/arm/mach-pxa/poodle.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -288,11 +289,19 @@ static struct pxamci_platform_data poodle_mci_platform_data = { .init = poodle_mci_init, .setpower = poodle_mci_setpower, .exit = poodle_mci_exit, - .gpio_card_detect = POODLE_GPIO_nSD_DETECT, - .gpio_card_ro = POODLE_GPIO_nSD_WP, .gpio_power = -1, }; +static struct gpiod_lookup_table poodle_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", POODLE_GPIO_nSD_DETECT, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", POODLE_GPIO_nSD_WP, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; /* * Irda @@ -439,6 +448,7 @@ static void __init poodle_init(void) pxa_set_fb_info(&poodle_locomo_device.dev, &poodle_fb_info); pxa_set_udc_info(&udc_info); + gpiod_add_lookup_table(&poodle_mci_gpio_table); pxa_set_mci_info(&poodle_mci_platform_data); pxa_set_ficp_info(&poodle_ficp_platform_data); pxa_set_i2c_info(NULL); diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index bd3c23ad6ce6..19b988d6dc44 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -749,8 +749,6 @@ static struct pxamci_platform_data raumfeld_mci_platform_data = { .init = raumfeld_mci_init, .exit = raumfeld_mci_exit, .detect_delay_ms = 200, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 5d50025492b7..7a9fe1749d7a 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -615,13 +616,23 @@ static struct pxamci_platform_data spitz_mci_platform_data = { .detect_delay_ms = 250, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .setpower = spitz_mci_setpower, - .gpio_card_detect = SPITZ_GPIO_nSD_DETECT, - .gpio_card_ro = SPITZ_GPIO_nSD_WP, .gpio_power = -1, }; +static struct gpiod_lookup_table spitz_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_nSD_DETECT, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_nSD_WP, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init spitz_mmc_init(void) { + gpiod_add_lookup_table(&spitz_mci_gpio_table); pxa_set_mci_info(&spitz_mci_platform_data); } #else diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c index bbea5fa9a140..0bdb414daedd 100644 --- a/arch/arm/mach-pxa/stargate2.c +++ b/arch/arm/mach-pxa/stargate2.c @@ -436,8 +436,6 @@ static int imote2_mci_get_ro(struct device *dev) static struct pxamci_platform_data imote2_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */ .get_ro = imote2_mci_get_ro, - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c index cb5cd8e78c94..934338b574da 100644 --- a/arch/arm/mach-pxa/tosa.c +++ b/arch/arm/mach-pxa/tosa.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -291,11 +292,20 @@ static struct pxamci_platform_data tosa_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .init = tosa_mci_init, .exit = tosa_mci_exit, - .gpio_card_detect = TOSA_GPIO_nSD_DETECT, - .gpio_card_ro = TOSA_GPIO_SD_WP, .gpio_power = TOSA_GPIO_PWR_ON, }; +static struct gpiod_lookup_table tosa_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_nSD_DETECT, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_SD_WP, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + /* * Irda */ @@ -908,6 +918,7 @@ static void __init tosa_init(void) /* enable batt_fault */ PMCR = 0x01; + gpiod_add_lookup_table(&tosa_mci_gpio_table); pxa_set_mci_info(&tosa_mci_platform_data); pxa_set_ficp_info(&tosa_ficp_platform_data); pxa_set_i2c_info(NULL); diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c index 55b8c501b6fc..849f8b0e6651 100644 --- a/arch/arm/mach-pxa/trizeps4.c +++ b/arch/arm/mach-pxa/trizeps4.c @@ -355,8 +355,6 @@ static struct pxamci_platform_data trizeps4_mci_platform_data = { .exit = trizeps4_mci_exit, .get_ro = NULL, /* write-protection not supported */ .setpower = NULL, /* power-switching not supported */ - .gpio_card_detect = -1, - .gpio_card_ro = -1, .gpio_power = -1, }; diff --git a/arch/arm/mach-pxa/vpac270.c b/arch/arm/mach-pxa/vpac270.c index f65dfb6e20e2..186c75161df8 100644 --- a/arch/arm/mach-pxa/vpac270.c +++ b/arch/arm/mach-pxa/vpac270.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -241,13 +242,23 @@ static void __init vpac270_onenand_init(void) {} static struct pxamci_platform_data vpac270_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, .gpio_power = -1, - .gpio_card_detect = GPIO53_VPAC270_SD_DETECT_N, - .gpio_card_ro = GPIO52_VPAC270_SD_READONLY, .detect_delay_ms = 200, }; +static struct gpiod_lookup_table vpac270_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO53_VPAC270_SD_DETECT_N, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO52_VPAC270_SD_READONLY, + "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init vpac270_mmc_init(void) { + gpiod_add_lookup_table(&vpac270_mci_gpio_table); pxa_set_mci_info(&vpac270_mci_platform_data); } #else diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c index 6fffcfc4621e..d2a63c16404e 100644 --- a/arch/arm/mach-pxa/z2.c +++ b/arch/arm/mach-pxa/z2.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -290,14 +291,22 @@ static inline void z2_lcd_init(void) {} #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) static struct pxamci_platform_data z2_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_card_detect = GPIO96_ZIPITZ2_SD_DETECT, .gpio_power = -1, - .gpio_card_ro = -1, .detect_delay_ms = 200, }; +static struct gpiod_lookup_table z2_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO96_ZIPITZ2_SD_DETECT, + "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init z2_mmc_init(void) { + gpiod_add_lookup_table(&z2_mci_gpio_table); pxa_set_mci_info(&z2_mci_platform_data); } #else diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c index d53ea12fc766..8c71e47e33c4 100644 --- a/arch/arm/mach-pxa/zeus.c +++ b/arch/arm/mach-pxa/zeus.c @@ -663,12 +663,21 @@ static struct pxafb_mach_info zeus_fb_info = { static struct pxamci_platform_data zeus_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .detect_delay_ms = 250, - .gpio_card_detect = ZEUS_MMC_CD_GPIO, - .gpio_card_ro = ZEUS_MMC_WP_GPIO, .gpio_card_ro_invert = 1, .gpio_power = -1 }; +static struct gpiod_lookup_table zeus_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("gpio-pxa", ZEUS_MMC_CD_GPIO, + "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", ZEUS_MMC_WP_GPIO, + "wp", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* * USB Device Controller */ @@ -883,6 +892,7 @@ static void __init zeus_init(void) else pxa_set_fb_info(NULL, &zeus_fb_info); + gpiod_add_lookup_table(&zeus_mci_gpio_table); pxa_set_mci_info(&zeus_mci_platform_data); pxa_set_udc_info(&zeus_udc_info); pxa_set_ac97_info(&zeus_ac97_info); diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c index 52e70a5c1281..5617f17a91d0 100644 --- a/arch/arm/mach-pxa/zylonite.c +++ b/arch/arm/mach-pxa/zylonite.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -227,33 +227,58 @@ static inline void zylonite_init_lcd(void) {} static struct pxamci_platform_data zylonite_mci_platform_data = { .detect_delay_ms= 200, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_card_detect = EXT_GPIO(0), - .gpio_card_ro = EXT_GPIO(2), .gpio_power = -1, }; +static struct gpiod_lookup_table zylonite_mci_gpio_table = { + .dev_id = "pxa2xx-mci.0", + .table = { + GPIO_LOOKUP("pca9539", 0, "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("pca9539", 2, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct pxamci_platform_data zylonite_mci2_platform_data = { .detect_delay_ms= 200, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_card_detect = EXT_GPIO(1), - .gpio_card_ro = EXT_GPIO(3), .gpio_power = -1, }; +static struct gpiod_lookup_table zylonite_mci2_gpio_table = { + .dev_id = "pxa2xx-mci.1", + .table = { + GPIO_LOOKUP("pca9539", 1, "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("pca9539", 3, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct pxamci_platform_data zylonite_mci3_platform_data = { .detect_delay_ms= 200, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_card_detect = EXT_GPIO(30), - .gpio_card_ro = EXT_GPIO(31), .gpio_power = -1, }; +static struct gpiod_lookup_table zylonite_mci3_gpio_table = { + .dev_id = "pxa2xx-mci.2", + .table = { + GPIO_LOOKUP("pca9539", 30, "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("pca9539", 31, "wp", GPIO_ACTIVE_LOW), + { }, + }, +}; + static void __init zylonite_init_mmc(void) { + gpiod_add_lookup_table(&zylonite_mci_gpio_table); pxa_set_mci_info(&zylonite_mci_platform_data); + gpiod_add_lookup_table(&zylonite_mci2_gpio_table); pxa3xx_set_mci2_info(&zylonite_mci2_platform_data); - if (cpu_is_pxa310()) + if (cpu_is_pxa310()) { + gpiod_add_lookup_table(&zylonite_mci3_gpio_table); pxa3xx_set_mci3_info(&zylonite_mci3_platform_data); + } } #else static inline void zylonite_init_mmc(void) {} diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index f7ffbf1676b1..a8b6c14f2687 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -63,6 +62,7 @@ struct pxamci_host { unsigned int imask; unsigned int power_mode; unsigned long detect_delay_ms; + bool use_ro_gpio; struct pxamci_platform_data *pdata; struct mmc_request *mrq; @@ -432,7 +432,7 @@ static int pxamci_get_ro(struct mmc_host *mmc) { struct pxamci_host *host = mmc_priv(mmc); - if (host->pdata && gpio_is_valid(host->pdata->gpio_card_ro)) + if (host->use_ro_gpio) return mmc_gpio_get_ro(mmc); if (host->pdata && host->pdata->get_ro) return !!host->pdata->get_ro(mmc_dev(mmc)); @@ -730,8 +730,6 @@ static int pxamci_probe(struct platform_device *pdev) } if (host->pdata) { - int gpio_cd = host->pdata->gpio_card_detect; - int gpio_ro = host->pdata->gpio_card_ro; int gpio_power = host->pdata->gpio_power; host->detect_delay_ms = host->pdata->detect_delay_ms; @@ -749,33 +747,30 @@ static int pxamci_probe(struct platform_device *pdev) host->pdata->gpio_power_invert); } - if (gpio_is_valid(gpio_ro)) { - ret = mmc_gpio_request_ro(mmc, gpio_ro); - if (ret) { - dev_err(dev, - "Failed requesting gpio_ro %d\n", - gpio_ro); - goto out; - } else { - mmc->caps2 |= host->pdata->gpio_card_ro_invert ? - 0 : MMC_CAP2_RO_ACTIVE_HIGH; - } + /* FIXME: should we pass detection delay to debounce? */ + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); + if (ret && ret != -ENOENT) { + dev_err(dev, "Failed requesting gpio_cd\n"); + goto out; } - if (gpio_is_valid(gpio_cd)) - ret = mmc_gpio_request_cd(mmc, gpio_cd, 0); - if (ret) { - dev_err(dev, "Failed requesting gpio_cd %d\n", - gpio_cd); + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL); + if (ret && ret != -ENOENT) { + dev_err(dev, "Failed requesting gpio_ro\n"); goto out; } + if (!ret) { + host->use_ro_gpio = true; + mmc->caps2 |= host->pdata->gpio_card_ro_invert ? + 0 : MMC_CAP2_RO_ACTIVE_HIGH; + } if (host->pdata->init) host->pdata->init(dev, pxamci_detect_irq, mmc); if (gpio_is_valid(gpio_power) && host->pdata->setpower) dev_warn(dev, "gpio_power and setpower() both defined\n"); - if (gpio_is_valid(gpio_ro) && host->pdata->get_ro) + if (host->use_ro_gpio && host->pdata->get_ro) dev_warn(dev, "gpio_ro and get_ro() both defined\n"); } diff --git a/include/linux/platform_data/mmc-pxamci.h b/include/linux/platform_data/mmc-pxamci.h index 752f97c62ef2..db6c247d42d1 100644 --- a/include/linux/platform_data/mmc-pxamci.h +++ b/include/linux/platform_data/mmc-pxamci.h @@ -15,8 +15,6 @@ struct pxamci_platform_data { int (*get_ro)(struct device *); int (*setpower)(struct device *, unsigned int); void (*exit)(struct device *, void *); - int gpio_card_detect; /* gpio detecting card insertion */ - int gpio_card_ro; /* gpio detecting read only toggle */ bool gpio_card_ro_invert; /* gpio ro is inverted */ int gpio_power; /* gpio powering up MMC bus */ bool gpio_power_invert; /* gpio power is inverted */ From patchwork Mon Nov 12 14:12:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150848 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3191206ljp; Mon, 12 Nov 2018 06:13:13 -0800 (PST) X-Google-Smtp-Source: AJdET5d42x4ADY8Ygy4TaFdumUPPUEudPSHV9Ae0QKk4k34bMf95JFDGNApyMQOVXsDpm2vM50tM X-Received: by 2002:a63:a064:: with SMTP id u36mr971280pgn.145.1542031993743; Mon, 12 Nov 2018 06:13:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031993; cv=none; d=google.com; s=arc-20160816; b=0zrT/fcdkC6YwN7+KQkyUou+TMGONINSj+fyOADwhcZ97fqrTvpz9CQ3nSlAu9GL51 s7qsYbLC+mId7uB4frJktFaah8KyNwk0D2fDW3v8H/+4tsCeYHC1ajS6x8d3NQxgp8LW HcgW50weqKbF2qI6EdO7ol933glEk7tVSaz7Qzk3TaqjqdBxcWDe3gaSqUnvOKNpN16H udJ6LVEfb9fEUSCAxCULaAq3WZDXjTO2p87MxDU3bkk4/8CF9wf19nUN/N28FErgIXOE 5lRgDehRK8Gd8r7mEG5JvItgZyhxXwL+LBJ2g+gyLAtBOnJRabC4Zf/dv2yi9B+Ps46x Yh/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=wNKQ3Mrj/L2Y/zriPfE44EdgODmRGqVsJ7lr54Da5R4=; b=ZUTPWiT0ne2XEqdG+EWzX+4sUVP7vOhnqrcc8kxGJpLHAo2iTV02aUxyDxgCMNJeC5 7OnfwJ0Oqp71B3CYgp3QEX/rfxoLL7U3uFw9kTNJK/tbt+YzT6/bqrguY4wZo62M3lJ3 6t9TR0/UjNxU11mSIu9KJ0kqj8VD6R5DGqMWJm/WKSDWTdrV0fqKk7RLnqZ0Vq4S7EcM MYMR/D6BBq+q5Wm35xO54orveLac8y0U1bixb6hxrcmKqS578ezIm3EaCBGeWrp8xYAu O+H5TtKXIAF9PSvo6a34WKU2Z0I3FwIvF4HEHhzwoddcvsHVnZC+VRlO5vU9+dhCCAmz Sftw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hfWMBIVF; 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 h68-v6si19277640pfb.142.2018.11.12.06.13.13; Mon, 12 Nov 2018 06:13:13 -0800 (PST) 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=hfWMBIVF; 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 S1729800AbeKMAGj (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:39 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:46770 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729772AbeKMAGj (ORCPT ); Mon, 12 Nov 2018 19:06:39 -0500 Received: by mail-lf1-f68.google.com with SMTP id f23so6255955lfc.13 for ; Mon, 12 Nov 2018 06:13:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wNKQ3Mrj/L2Y/zriPfE44EdgODmRGqVsJ7lr54Da5R4=; b=hfWMBIVFOMqP+xwcVSlZpzxNr8phYs3Xi/FpIqoXzhpBOOczZL9xy5OJEtpMfq9n6C nYIYYSIwatTWc8Wh2DS73gh/YV5H9VBkDJDAPiY4slk+Uhf0ygU69Rl/3pA17KXDNXZf YPWl7DlzzE9veNth8MUyX5B6XMy9d2c6t+hRI= 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:in-reply-to :references; bh=wNKQ3Mrj/L2Y/zriPfE44EdgODmRGqVsJ7lr54Da5R4=; b=kM/9xaD2CUnfUC/EOKF3izRG1P2UnKxWpa7NssIL2B3QS/AZZlD7u3G1KGZmFtCxpo pNZtOoMbWHyKgrI6JJ7AEMv4dXr7blGHcTBdgSdNYdZqBmirXFT8rWlnz5V6KXHLJlT+ Qv8dkqkuoqza/SslRQgSxs5p6r85IMKk7nf4GdZRT1w6m8uqg1tLMEHt0jWa9hyo2EYP dxu5RrZcLJuKHi2QL8YuKh6HKByME/rlvPRUo2ETXqCVAbIg6PCXNqvm/RspkVJC3dUl 5BFmFbenHgmAlecsBzUS6XEo++uoQOyDCxR7bL37hWIGGekvkvMRe/2ZzU7hdHsodWPa i00w== X-Gm-Message-State: AGRZ1gLgLSpJ3C9hOnR9bCW4BcV5AbzLIJCp6zEGqWlexblTeuDxSu0D J933e0U9Hnwpj2v8YCxHpi1z/23KHw14AQ== X-Received: by 2002:a19:5059:: with SMTP id z25mr722042lfj.120.1542031986871; Mon, 12 Nov 2018 06:13:06 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.13.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:13:05 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Daniel Mack , Robert Jarzmik , Bartosz Golaszewski , Andrea Adami Subject: [PATCH 09/10] mmc: pxa: Use GPIO descriptor for power Date: Mon, 12 Nov 2018 15:12:38 +0100 Message-Id: <20181112141239.19646-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org After converting the PXA driver to use GPIO descriptors for card detect and write protect it is relatively simple to convert it to also use a descriptor for getting the optional power control GPIO. The polarity inversion flag can also go away from the platform data since this is indicated in the GPIO machine descriptor table. Cc: Daniel Mack Cc: Robert Jarzmik Cc: Bartosz Golaszewski Cc: Andrea Adami Signed-off-by: Linus Walleij --- arch/arm/mach-pxa/balloon3.c | 1 - arch/arm/mach-pxa/cm-x270.c | 4 +-- arch/arm/mach-pxa/cm-x300.c | 2 -- arch/arm/mach-pxa/colibri-pxa270-income.c | 1 - arch/arm/mach-pxa/corgi.c | 4 ++- arch/arm/mach-pxa/csb726.c | 1 - arch/arm/mach-pxa/em-x270.c | 1 - arch/arm/mach-pxa/gumstix.c | 1 - arch/arm/mach-pxa/idp.c | 1 - arch/arm/mach-pxa/littleton.c | 1 - arch/arm/mach-pxa/lubbock.c | 1 - arch/arm/mach-pxa/magician.c | 7 ++++- arch/arm/mach-pxa/mainstone.c | 1 - arch/arm/mach-pxa/mioa701.c | 3 ++- arch/arm/mach-pxa/mxm8x10.c | 1 - arch/arm/mach-pxa/palm27x.c | 6 +---- arch/arm/mach-pxa/palm27x.h | 8 ++---- arch/arm/mach-pxa/palmld.c | 5 ++-- arch/arm/mach-pxa/palmt5.c | 5 ++-- arch/arm/mach-pxa/palmtc.c | 3 ++- arch/arm/mach-pxa/palmte2.c | 3 ++- arch/arm/mach-pxa/palmtreo.c | 10 +++++--- arch/arm/mach-pxa/palmtx.c | 5 ++-- arch/arm/mach-pxa/palmz72.c | 5 ++-- arch/arm/mach-pxa/pcm990-baseboard.c | 1 - arch/arm/mach-pxa/poodle.c | 1 - arch/arm/mach-pxa/raumfeld.c | 1 - arch/arm/mach-pxa/spitz.c | 1 - arch/arm/mach-pxa/stargate2.c | 1 - arch/arm/mach-pxa/tosa.c | 3 ++- arch/arm/mach-pxa/trizeps4.c | 1 - arch/arm/mach-pxa/vpac270.c | 1 - arch/arm/mach-pxa/z2.c | 1 - arch/arm/mach-pxa/zeus.c | 1 - arch/arm/mach-pxa/zylonite.c | 3 --- drivers/mmc/host/pxamci.c | 31 ++++++++--------------- include/linux/platform_data/mmc-pxamci.h | 2 -- 37 files changed, 50 insertions(+), 78 deletions(-) -- 2.17.2 diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c index 612109c515da..4bcbd3d55b36 100644 --- a/arch/arm/mach-pxa/balloon3.c +++ b/arch/arm/mach-pxa/balloon3.c @@ -290,7 +290,6 @@ static unsigned long balloon3_mmc_pin_config[] __initdata = { static struct pxamci_platform_data balloon3_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = -1, .detect_delay_ms = 200, }; diff --git a/arch/arm/mach-pxa/cm-x270.c b/arch/arm/mach-pxa/cm-x270.c index 8c530fcd87d9..fe9665b64e2f 100644 --- a/arch/arm/mach-pxa/cm-x270.c +++ b/arch/arm/mach-pxa/cm-x270.c @@ -284,8 +284,6 @@ static inline void cmx270_init_ohci(void) {} #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) static struct pxamci_platform_data cmx270_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_power = GPIO105_MMC_POWER, - .gpio_power_invert = 1, }; static struct gpiod_lookup_table cmx270_mci_gpio_table = { @@ -293,6 +291,8 @@ static struct gpiod_lookup_table cmx270_mci_gpio_table = { .table = { /* Card detect on GPIO 83 */ GPIO_LOOKUP("gpio-pxa", 83, "cd", GPIO_ACTIVE_LOW), + /* Power on GPIO 105 */ + GPIO_LOOKUP("gpio-pxa", 105, "power", GPIO_ACTIVE_LOW), { }, }, }; diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c index 93a2d5b58f84..57ded62e1e52 100644 --- a/arch/arm/mach-pxa/cm-x300.c +++ b/arch/arm/mach-pxa/cm-x300.c @@ -454,7 +454,6 @@ static inline void cm_x300_init_nand(void) {} static struct pxamci_platform_data cm_x300_mci_platform_data = { .detect_delay_ms = 200, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_power = -1, }; static struct gpiod_lookup_table cm_x300_mci_gpio_table = { @@ -486,7 +485,6 @@ static struct pxamci_platform_data cm_x300_mci2_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .init = cm_x300_mci2_init, .exit = cm_x300_mci2_exit, - .gpio_power = -1, }; static void __init cm_x300_init_mmc(void) diff --git a/arch/arm/mach-pxa/colibri-pxa270-income.c b/arch/arm/mach-pxa/colibri-pxa270-income.c index 3554e6befbb8..5cd4dcd9413b 100644 --- a/arch/arm/mach-pxa/colibri-pxa270-income.c +++ b/arch/arm/mach-pxa/colibri-pxa270-income.c @@ -49,7 +49,6 @@ #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) static struct pxamci_platform_data income_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = -1, .detect_delay_ms = 200, }; diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index d57a3738a200..c9732cace5e3 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c @@ -494,7 +494,6 @@ static struct platform_device corgi_audio_device = { static struct pxamci_platform_data corgi_mci_platform_data = { .detect_delay_ms = 250, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_power = CORGI_GPIO_SD_PWR, }; static struct gpiod_lookup_table corgi_mci_gpio_table = { @@ -506,6 +505,9 @@ static struct gpiod_lookup_table corgi_mci_gpio_table = { /* Write protect on GPIO 7 */ GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_nSD_WP, "wp", GPIO_ACTIVE_LOW), + /* Power on GPIO 33 */ + GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_SD_PWR, + "power", GPIO_ACTIVE_HIGH), { }, }, }; diff --git a/arch/arm/mach-pxa/csb726.c b/arch/arm/mach-pxa/csb726.c index f00e0c12f63e..e26e7e60a169 100644 --- a/arch/arm/mach-pxa/csb726.c +++ b/arch/arm/mach-pxa/csb726.c @@ -129,7 +129,6 @@ static struct pxamci_platform_data csb726_mci = { .detect_delay_ms = 500, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, /* FIXME setpower */ - .gpio_power = -1, }; static struct gpiod_lookup_table csb726_mci_gpio_table = { diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c index e41d94e3c2c3..32c1edeb3f14 100644 --- a/arch/arm/mach-pxa/em-x270.c +++ b/arch/arm/mach-pxa/em-x270.c @@ -630,7 +630,6 @@ static struct pxamci_platform_data em_x270_mci_platform_data = { .init = em_x270_mci_init, .setpower = em_x270_mci_setpower, .exit = em_x270_mci_exit, - .gpio_power = -1, }; static void __init em_x270_init_mmc(void) diff --git a/arch/arm/mach-pxa/gumstix.c b/arch/arm/mach-pxa/gumstix.c index fef80dc401de..4764acca5480 100644 --- a/arch/arm/mach-pxa/gumstix.c +++ b/arch/arm/mach-pxa/gumstix.c @@ -90,7 +90,6 @@ static struct platform_device *devices[] __initdata = { #ifdef CONFIG_MMC_PXA static struct pxamci_platform_data gumstix_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_power = -1, }; static void __init gumstix_mmc_init(void) diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c index a03b23c2fee9..7bfc246a1d75 100644 --- a/arch/arm/mach-pxa/idp.c +++ b/arch/arm/mach-pxa/idp.c @@ -160,7 +160,6 @@ static struct pxafb_mach_info sharp_lm8v31 = { static struct pxamci_platform_data idp_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_power = -1, }; static void __init idp_init(void) diff --git a/arch/arm/mach-pxa/littleton.c b/arch/arm/mach-pxa/littleton.c index 704a0effba3d..4f720f77572b 100644 --- a/arch/arm/mach-pxa/littleton.c +++ b/arch/arm/mach-pxa/littleton.c @@ -276,7 +276,6 @@ static inline void littleton_init_keypad(void) {} static struct pxamci_platform_data littleton_mci_platform_data = { .detect_delay_ms = 200, .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = -1, }; static struct gpiod_lookup_table littleton_mci_gpio_table = { diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c index 469cbc6b747f..c576e8462043 100644 --- a/arch/arm/mach-pxa/lubbock.c +++ b/arch/arm/mach-pxa/lubbock.c @@ -440,7 +440,6 @@ static struct pxamci_platform_data lubbock_mci_platform_data = { .init = lubbock_mci_init, .get_ro = lubbock_mci_get_ro, .exit = lubbock_mci_exit, - .gpio_power = -1, }; static void lubbock_irda_transceiver_mode(struct device *dev, int mode) diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index 3e515394b20a..ee1a49c95e40 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -776,7 +776,6 @@ static struct pxamci_platform_data magician_mci_info = { .init = magician_mci_init, .exit = magician_mci_exit, .gpio_card_ro_invert = 1, - .gpio_power = EGPIO_MAGICIAN_SD_POWER, }; static struct gpiod_lookup_table magician_mci_gpio_table = { @@ -788,6 +787,12 @@ static struct gpiod_lookup_table magician_mci_gpio_table = { * 4, so we need offset 8+4=12 on that particular chip. */ GPIO_LOOKUP("htc-egpio-1", 12, "wp", GPIO_ACTIVE_HIGH), + /* + * Power on EGPIO register 2 index 0, so this is on + * the first HTC EGPIO chip starting at register 0 so we + * need offset 2*8+0 = 16 on that chip. + */ + GPIO_LOOKUP("htc-egpio-0", 16, "power", GPIO_ACTIVE_HIGH), { }, }, }; diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c index 31142b17d845..9e39fc2ad2d9 100644 --- a/arch/arm/mach-pxa/mainstone.c +++ b/arch/arm/mach-pxa/mainstone.c @@ -361,7 +361,6 @@ static struct pxamci_platform_data mainstone_mci_platform_data = { .init = mainstone_mci_init, .setpower = mainstone_mci_setpower, .exit = mainstone_mci_exit, - .gpio_power = -1, }; static void mainstone_irda_transceiver_mode(struct device *dev, int mode) diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c index d2941c256233..589ac76002ff 100644 --- a/arch/arm/mach-pxa/mioa701.c +++ b/arch/arm/mach-pxa/mioa701.c @@ -398,7 +398,6 @@ struct gpio_vbus_mach_info gpio_vbus_data = { static struct pxamci_platform_data mioa701_mci_info = { .detect_delay_ms = 250, .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = GPIO91_SDIO_EN, }; static struct gpiod_lookup_table mioa701_mci_gpio_table = { @@ -408,6 +407,8 @@ static struct gpiod_lookup_table mioa701_mci_gpio_table = { GPIO_LOOKUP("gpio-pxa", 15, "cd", GPIO_ACTIVE_LOW), /* Write protect on GPIO 78 */ GPIO_LOOKUP("gpio-pxa", 78, "wp", GPIO_ACTIVE_LOW), + /* Power on GPIO 91 */ + GPIO_LOOKUP("gpio-pxa", 91, "power", GPIO_ACTIVE_HIGH), { }, }, }; diff --git a/arch/arm/mach-pxa/mxm8x10.c b/arch/arm/mach-pxa/mxm8x10.c index d1562e35644c..b2681d6ba562 100644 --- a/arch/arm/mach-pxa/mxm8x10.c +++ b/arch/arm/mach-pxa/mxm8x10.c @@ -326,7 +326,6 @@ static mfp_cfg_t mfp_cfg[] __initdata = { static struct pxamci_platform_data mxm_8x10_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, .detect_delay_ms = 10, - .gpio_power = -1 }; static struct gpiod_lookup_table mxm_8x10_mci_gpio_table = { diff --git a/arch/arm/mach-pxa/palm27x.c b/arch/arm/mach-pxa/palm27x.c index 62b37fecfdcb..b94c45f65215 100644 --- a/arch/arm/mach-pxa/palm27x.c +++ b/arch/arm/mach-pxa/palm27x.c @@ -49,12 +49,8 @@ static struct pxamci_platform_data palm27x_mci_platform_data = { .detect_delay_ms = 200, }; -void __init palm27x_mmc_init(struct gpiod_lookup_table *gtable, int power, - int power_inverted) +void __init palm27x_mmc_init(struct gpiod_lookup_table *gtable) { - palm27x_mci_platform_data.gpio_power = power; - palm27x_mci_platform_data.gpio_power_invert = power_inverted; - if (gtable) gpiod_add_lookup_table(gtable); pxa_set_mci_info(&palm27x_mci_platform_data); diff --git a/arch/arm/mach-pxa/palm27x.h b/arch/arm/mach-pxa/palm27x.h index 05e3f04c11e2..cd071f876132 100644 --- a/arch/arm/mach-pxa/palm27x.h +++ b/arch/arm/mach-pxa/palm27x.h @@ -15,13 +15,9 @@ #include #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) -extern void __init palm27x_mmc_init(struct gpiod_lookup_table *gtable, - int power, - int power_inverted); +extern void __init palm27x_mmc_init(struct gpiod_lookup_table *gtable); #else -static inline void palm27x_mmc_init(struct gpiod_lookup_table *gtable, - int power, - int power_inverted) +static inline void palm27x_mmc_init(struct gpiod_lookup_table *gtable) {} #endif diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c index 63d81c1a3103..93d1124d21c2 100644 --- a/arch/arm/mach-pxa/palmld.c +++ b/arch/arm/mach-pxa/palmld.c @@ -327,6 +327,8 @@ static struct gpiod_lookup_table palmld_mci_gpio_table = { "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_READONLY, "wp", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_POWER, + "power", GPIO_ACTIVE_HIGH), { }, }, }; @@ -338,8 +340,7 @@ static void __init palmld_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); - palm27x_mmc_init(&palmld_mci_gpio_table, - GPIO_NR_PALMLD_SD_POWER, 0); + palm27x_mmc_init(&palmld_mci_gpio_table); palm27x_pm_init(PALMLD_STR_BASE); palm27x_lcd_init(-1, &palm_320x480_lcd_mode); palm27x_irda_init(GPIO_NR_PALMLD_IR_DISABLE); diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c index 81a37116081b..8811f11f670e 100644 --- a/arch/arm/mach-pxa/palmt5.c +++ b/arch/arm/mach-pxa/palmt5.c @@ -189,6 +189,8 @@ static struct gpiod_lookup_table palmt5_mci_gpio_table = { "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_READONLY, "wp", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_POWER, + "power", GPIO_ACTIVE_HIGH), { }, }, }; @@ -200,8 +202,7 @@ static void __init palmt5_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); - palm27x_mmc_init(&palmt5_mci_gpio_table, - GPIO_NR_PALMT5_SD_POWER, 0); + palm27x_mmc_init(&palmt5_mci_gpio_table); palm27x_pm_init(PALMT5_STR_BASE); palm27x_lcd_init(-1, &palm_320x480_lcd_mode); palm27x_udc_init(GPIO_NR_PALMT5_USB_DETECT_N, diff --git a/arch/arm/mach-pxa/palmtc.c b/arch/arm/mach-pxa/palmtc.c index 7b4c686de8c2..7ce4fc287115 100644 --- a/arch/arm/mach-pxa/palmtc.c +++ b/arch/arm/mach-pxa/palmtc.c @@ -120,7 +120,6 @@ static unsigned long palmtc_pin_config[] __initdata = { #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) static struct pxamci_platform_data palmtc_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = GPIO_NR_PALMTC_SD_POWER, .detect_delay_ms = 200, }; @@ -131,6 +130,8 @@ static struct gpiod_lookup_table palmtc_mci_gpio_table = { "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_READONLY, "wp", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_POWER, + "power", GPIO_ACTIVE_HIGH), { }, }, }; diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c index 77cb2d98cbdd..e830005af8d0 100644 --- a/arch/arm/mach-pxa/palmte2.c +++ b/arch/arm/mach-pxa/palmte2.c @@ -102,7 +102,6 @@ static unsigned long palmte2_pin_config[] __initdata = { ******************************************************************************/ static struct pxamci_platform_data palmte2_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = GPIO_NR_PALMTE2_SD_POWER, }; static struct gpiod_lookup_table palmte2_mci_gpio_table = { @@ -112,6 +111,8 @@ static struct gpiod_lookup_table palmte2_mci_gpio_table = { "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_READONLY, "wp", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_POWER, + "power", GPIO_ACTIVE_HIGH), { }, }, }; diff --git a/arch/arm/mach-pxa/palmtreo.c b/arch/arm/mach-pxa/palmtreo.c index ea44f699240f..70f1a8a3aa94 100644 --- a/arch/arm/mach-pxa/palmtreo.c +++ b/arch/arm/mach-pxa/palmtreo.c @@ -487,6 +487,8 @@ static struct gpiod_lookup_table treo680_mci_gpio_table = { "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_READONLY, "wp", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_POWER, + "power", GPIO_ACTIVE_HIGH), { }, }, }; @@ -496,8 +498,7 @@ static void __init treo680_init(void) pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config)); palmphone_common_init(); treo680_gpio_init(); - palm27x_mmc_init(&treo680_mci_gpio_table, - GPIO_NR_TREO680_SD_POWER, 0); + palm27x_mmc_init(&treo680_mci_gpio_table); } #endif @@ -508,6 +509,8 @@ static struct gpiod_lookup_table centro685_mci_gpio_table = { .table = { GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N, "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_CENTRO_SD_POWER, + "power", GPIO_ACTIVE_LOW), { }, }, }; @@ -516,8 +519,7 @@ static void __init centro_init(void) { pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config)); palmphone_common_init(); - palm27x_mmc_init(¢ro685_mci_gpio_table, - GPIO_NR_CENTRO_SD_POWER, 1); + palm27x_mmc_init(¢ro685_mci_gpio_table); } #endif diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c index 9df7cd84ba7b..ef71bf2abb47 100644 --- a/arch/arm/mach-pxa/palmtx.c +++ b/arch/arm/mach-pxa/palmtx.c @@ -344,6 +344,8 @@ static struct gpiod_lookup_table palmtx_mci_gpio_table = { "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_READONLY, "wp", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_POWER, + "power", GPIO_ACTIVE_HIGH), { }, }, }; @@ -355,8 +357,7 @@ static void __init palmtx_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); - palm27x_mmc_init(&palmtx_mci_gpio_table, - GPIO_NR_PALMTX_SD_POWER, 0); + palm27x_mmc_init(&palmtx_mci_gpio_table); palm27x_pm_init(PALMTX_STR_BASE); palm27x_lcd_init(-1, &palm_320x480_lcd_mode); palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N, diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c index febf5aadbde6..ea1c7b2ed8d4 100644 --- a/arch/arm/mach-pxa/palmz72.c +++ b/arch/arm/mach-pxa/palmz72.c @@ -393,6 +393,8 @@ static struct gpiod_lookup_table palmz72_mci_gpio_table = { "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_RO, "wp", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_POWER_N, + "power", GPIO_ACTIVE_LOW), { }, }, }; @@ -407,8 +409,7 @@ static void __init palmz72_init(void) pxa_set_btuart_info(NULL); pxa_set_stuart_info(NULL); - palm27x_mmc_init(&palmz72_mci_gpio_table, - GPIO_NR_PALMZ72_SD_POWER_N, 1); + palm27x_mmc_init(&palmz72_mci_gpio_table); palm27x_lcd_init(-1, &palm_320x320_lcd_mode); palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N, GPIO_NR_PALMZ72_USB_PULLUP, 0); diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c index f76d7665420e..be19e3a4eacc 100644 --- a/arch/arm/mach-pxa/pcm990-baseboard.c +++ b/arch/arm/mach-pxa/pcm990-baseboard.c @@ -370,7 +370,6 @@ static struct pxamci_platform_data pcm990_mci_platform_data = { .init = pcm990_mci_init, .setpower = pcm990_mci_setpower, .exit = pcm990_mci_exit, - .gpio_power = -1, }; static struct pxaohci_platform_data pcm990_ohci_platform_data = { diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c index 9b8663ac532f..c2a43d4cfd3e 100644 --- a/arch/arm/mach-pxa/poodle.c +++ b/arch/arm/mach-pxa/poodle.c @@ -289,7 +289,6 @@ static struct pxamci_platform_data poodle_mci_platform_data = { .init = poodle_mci_init, .setpower = poodle_mci_setpower, .exit = poodle_mci_exit, - .gpio_power = -1, }; static struct gpiod_lookup_table poodle_mci_gpio_table = { diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index 19b988d6dc44..e1db072756f2 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -749,7 +749,6 @@ static struct pxamci_platform_data raumfeld_mci_platform_data = { .init = raumfeld_mci_init, .exit = raumfeld_mci_exit, .detect_delay_ms = 200, - .gpio_power = -1, }; /* diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 7a9fe1749d7a..306818e2cf54 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -616,7 +616,6 @@ static struct pxamci_platform_data spitz_mci_platform_data = { .detect_delay_ms = 250, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .setpower = spitz_mci_setpower, - .gpio_power = -1, }; static struct gpiod_lookup_table spitz_mci_gpio_table = { diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c index 0bdb414daedd..e0d6c872270a 100644 --- a/arch/arm/mach-pxa/stargate2.c +++ b/arch/arm/mach-pxa/stargate2.c @@ -436,7 +436,6 @@ static int imote2_mci_get_ro(struct device *dev) static struct pxamci_platform_data imote2_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */ .get_ro = imote2_mci_get_ro, - .gpio_power = -1, }; static struct gpio_led imote2_led_pins[] = { diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c index 934338b574da..e8a93c088c35 100644 --- a/arch/arm/mach-pxa/tosa.c +++ b/arch/arm/mach-pxa/tosa.c @@ -292,7 +292,6 @@ static struct pxamci_platform_data tosa_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .init = tosa_mci_init, .exit = tosa_mci_exit, - .gpio_power = TOSA_GPIO_PWR_ON, }; static struct gpiod_lookup_table tosa_mci_gpio_table = { @@ -302,6 +301,8 @@ static struct gpiod_lookup_table tosa_mci_gpio_table = { "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_SD_WP, "wp", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_PWR_ON, + "power", GPIO_ACTIVE_HIGH), { }, }, }; diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c index 849f8b0e6651..c76f1daecfc9 100644 --- a/arch/arm/mach-pxa/trizeps4.c +++ b/arch/arm/mach-pxa/trizeps4.c @@ -355,7 +355,6 @@ static struct pxamci_platform_data trizeps4_mci_platform_data = { .exit = trizeps4_mci_exit, .get_ro = NULL, /* write-protection not supported */ .setpower = NULL, /* power-switching not supported */ - .gpio_power = -1, }; /**************************************************************************** diff --git a/arch/arm/mach-pxa/vpac270.c b/arch/arm/mach-pxa/vpac270.c index 186c75161df8..829284406fa3 100644 --- a/arch/arm/mach-pxa/vpac270.c +++ b/arch/arm/mach-pxa/vpac270.c @@ -241,7 +241,6 @@ static void __init vpac270_onenand_init(void) {} #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) static struct pxamci_platform_data vpac270_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = -1, .detect_delay_ms = 200, }; diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c index d2a63c16404e..e2353e75bb28 100644 --- a/arch/arm/mach-pxa/z2.c +++ b/arch/arm/mach-pxa/z2.c @@ -291,7 +291,6 @@ static inline void z2_lcd_init(void) {} #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) static struct pxamci_platform_data z2_mci_platform_data = { .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, - .gpio_power = -1, .detect_delay_ms = 200, }; diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c index 8c71e47e33c4..897ef59fbe0c 100644 --- a/arch/arm/mach-pxa/zeus.c +++ b/arch/arm/mach-pxa/zeus.c @@ -664,7 +664,6 @@ static struct pxamci_platform_data zeus_mci_platform_data = { .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, .detect_delay_ms = 250, .gpio_card_ro_invert = 1, - .gpio_power = -1 }; static struct gpiod_lookup_table zeus_mci_gpio_table = { diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c index 5617f17a91d0..8c8752f1684a 100644 --- a/arch/arm/mach-pxa/zylonite.c +++ b/arch/arm/mach-pxa/zylonite.c @@ -227,7 +227,6 @@ static inline void zylonite_init_lcd(void) {} static struct pxamci_platform_data zylonite_mci_platform_data = { .detect_delay_ms= 200, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_power = -1, }; static struct gpiod_lookup_table zylonite_mci_gpio_table = { @@ -242,7 +241,6 @@ static struct gpiod_lookup_table zylonite_mci_gpio_table = { static struct pxamci_platform_data zylonite_mci2_platform_data = { .detect_delay_ms= 200, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_power = -1, }; static struct gpiod_lookup_table zylonite_mci2_gpio_table = { @@ -257,7 +255,6 @@ static struct gpiod_lookup_table zylonite_mci2_gpio_table = { static struct pxamci_platform_data zylonite_mci3_platform_data = { .detect_delay_ms= 200, .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, - .gpio_power = -1, }; static struct gpiod_lookup_table zylonite_mci3_gpio_table = { diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index a8b6c14f2687..8779bbaa6b69 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,6 +63,7 @@ struct pxamci_host { unsigned int power_mode; unsigned long detect_delay_ms; bool use_ro_gpio; + struct gpio_desc *power; struct pxamci_platform_data *pdata; struct mmc_request *mrq; @@ -101,16 +102,13 @@ static inline int pxamci_set_power(struct pxamci_host *host, { struct mmc_host *mmc = host->mmc; struct regulator *supply = mmc->supply.vmmc; - int on; if (!IS_ERR(supply)) return mmc_regulator_set_ocr(mmc, supply, vdd); - if (host->pdata && - gpio_is_valid(host->pdata->gpio_power)) { - on = ((1 << vdd) & host->pdata->ocr_mask); - gpio_set_value(host->pdata->gpio_power, - !!on ^ host->pdata->gpio_power_invert); + if (host->power) { + bool on = !!((1 << vdd) & host->pdata->ocr_mask); + gpiod_set_value(host->power, on); } if (host->pdata && host->pdata->setpower) @@ -730,21 +728,12 @@ static int pxamci_probe(struct platform_device *pdev) } if (host->pdata) { - int gpio_power = host->pdata->gpio_power; - host->detect_delay_ms = host->pdata->detect_delay_ms; - if (gpio_is_valid(gpio_power)) { - ret = devm_gpio_request(dev, gpio_power, - "mmc card power"); - if (ret) { - dev_err(dev, - "Failed requesting gpio_power %d\n", - gpio_power); - goto out; - } - gpio_direction_output(gpio_power, - host->pdata->gpio_power_invert); + host->power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); + if (IS_ERR(host->power)) { + dev_err(dev, "Failed requesting gpio_power\n"); + goto out; } /* FIXME: should we pass detection delay to debounce? */ @@ -768,7 +757,7 @@ static int pxamci_probe(struct platform_device *pdev) if (host->pdata->init) host->pdata->init(dev, pxamci_detect_irq, mmc); - if (gpio_is_valid(gpio_power) && host->pdata->setpower) + if (host->power && host->pdata->setpower) dev_warn(dev, "gpio_power and setpower() both defined\n"); if (host->use_ro_gpio && host->pdata->get_ro) dev_warn(dev, "gpio_ro and get_ro() both defined\n"); diff --git a/include/linux/platform_data/mmc-pxamci.h b/include/linux/platform_data/mmc-pxamci.h index db6c247d42d1..7e44e84e7150 100644 --- a/include/linux/platform_data/mmc-pxamci.h +++ b/include/linux/platform_data/mmc-pxamci.h @@ -16,8 +16,6 @@ struct pxamci_platform_data { int (*setpower)(struct device *, unsigned int); void (*exit)(struct device *, void *); bool gpio_card_ro_invert; /* gpio ro is inverted */ - int gpio_power; /* gpio powering up MMC bus */ - bool gpio_power_invert; /* gpio power is inverted */ }; extern void pxa_set_mci_info(struct pxamci_platform_data *info); From patchwork Mon Nov 12 14:12:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150846 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3191194ljp; Mon, 12 Nov 2018 06:13:13 -0800 (PST) X-Google-Smtp-Source: AJdET5fI1P0kFo7FuSlIcoVZBAUkD8dSWfU5HE1U5i9Nxfe6LJs1qNY6+ofDp44i6ETfJRNQkVNW X-Received: by 2002:a62:3647:: with SMTP id d68-v6mr1088706pfa.66.1542031993039; Mon, 12 Nov 2018 06:13:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031993; cv=none; d=google.com; s=arc-20160816; b=zpvPzE2mhcEJA9LSxLLfb1u+Dy23Bjaqo8I//85wgEaOB5WhLOml5sQb14dtegqwpr kmBsW6h3Uk19yDSKpdzjstdcFInppJoFudiG/kMOu43o0YDJBvw0/K9yn4aWHaOCCMsI EvPgn+NkpDvz6gxNE1kHvchr0sv4Yck0/gLjYI5GfN8zmv2utvlXn0kRTMiOPjHQblTl uJDyYlk5Qrom2dauw3bCfbiDcZ7UiSdFQFkf34X9w2BggYsjur/RV/aauLTNmnLtKFvh SYKW9afdsP5eQiBnOrERdSyuAyDzv19RCo2S8ZLakfpjnuNRSPW154bHP/x0q0S/Nody q3SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=rt4TJGByCdN0FaMJGDsjlpkv/2YBVgH7VBlG47gGhdM=; b=vU1y3OdOL+IHHundiTXlNa7KSbUtKnHh9VmzdMZfWBIWi8POsuCt6VrEwsoK+6HS1T fNng2u/b6mduVrUZZV9mJEcoy+mR/E77AoVN5mMz7eEP+KykvNMDqAqZXTJb1cOc/hP9 XuYEotOUZW1cLGm2dpaR7gAfg9gWkR4cCkSqXfTBoHgdB1HJBm9/rNPi5luqnROoqrYB HXIJwRNdG5PZ61HJEy7EtrXfC3gltg0Vp25vgLN86v8KHAOSu50FxabSRuZbD//6Mw34 5j4rHLNAfnUDBVXZShKTsJo+EfffM6t2IDKxF3UVcPNJ5xBFnjLtwGOXJHy46ba2B/4+ awDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GtomwXd4; 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 h68-v6si19277640pfb.142.2018.11.12.06.13.12; Mon, 12 Nov 2018 06:13:13 -0800 (PST) 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=GtomwXd4; 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 S1727842AbeKMAGi (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:38 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42536 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729800AbeKMAGi (ORCPT ); Mon, 12 Nov 2018 19:06:38 -0500 Received: by mail-lj1-f195.google.com with SMTP id f3-v6so7719361ljk.9 for ; Mon, 12 Nov 2018 06:13:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rt4TJGByCdN0FaMJGDsjlpkv/2YBVgH7VBlG47gGhdM=; b=GtomwXd4vXNr2uoVrRDiWF59fxXmMKtDDsft+18yFgAIncs+k5w7k/O/m75dyb/oqu Peg3VfHMC2XQrCaH/vEBt6vJ91S8asZfuoizhoJCqtTB0vHo9sz2kQbHF2VF6e/tiFfx 173FzdWbSFpTiav0KCKhmloe10OEhLlzQl0gI= 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:in-reply-to :references; bh=rt4TJGByCdN0FaMJGDsjlpkv/2YBVgH7VBlG47gGhdM=; b=C7/cejqbQhOZNtYvoPuazcVgvP7jFt6ry3gQCHVFTRYdwc7LcED4rq6dr6r3smERuo SM/BbZUopULBkucHSZRsh8ZwgnZe/zao+oMBGFa70rj04dPmmQZQSBN6SG47C1pCpM80 NTXM/7dSEBFAbw0UzFgVfHfdTthm/1UrgmcWzcRTr7uRt+yQOMAYlctQmKLxF59Rw7RB qjD3ploYZb96gZIgk6B2BtseiPJI0x6AsI848Z2frypo7nS+cNhiR9IFqbsoNPGyTgWr 0I069f1wM0a1Z/yCrxcP76UcXn5ElqFLkydZaToFyitJPfnkl4fiyMs6jdeXfFNojs3P FYuA== X-Gm-Message-State: AGRZ1gLc7VjjCjr6/lnL0HOoMKyigNKZFhLb0JAIWHwEL9avSTChDem4 1kU2ZWnnBGVYZ8UvEg0+m+E/jgyrSW778A== X-Received: by 2002:a2e:5654:: with SMTP id k81-v6mr795293ljb.48.1542031988783; Mon, 12 Nov 2018 06:13:08 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.13.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:13:07 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij Subject: [PATCH 10/10] mmc: slot-gpio: Delete legacy GPIO handling Date: Mon, 12 Nov 2018 15:12:39 +0100 Message-Id: <20181112141239.19646-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org All host drivers are converted to look up GPIO descriptors from device tree, ACPI or machine descriptor tables, so now we can delete the legacy GPIO handling using hardcoded GPIO numbers from the kernel. Signed-off-by: Linus Walleij --- drivers/mmc/core/slot-gpio.c | 81 +---------------------------------- include/linux/mmc/slot-gpio.h | 5 --- 2 files changed, 1 insertion(+), 85 deletions(-) -- 2.17.2 diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index e5bb86b02373..319ccd93383d 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -9,7 +9,6 @@ */ #include -#include #include #include #include @@ -102,36 +101,6 @@ int mmc_gpio_get_cd(struct mmc_host *host) } EXPORT_SYMBOL(mmc_gpio_get_cd); -/** - * mmc_gpio_request_ro - request a gpio for write-protection - * @host: mmc host - * @gpio: gpio number requested - * - * As devm_* managed functions are used in mmc_gpio_request_ro(), client - * drivers do not need to worry about freeing up memory. - * - * Returns zero on success, else an error. - */ -int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) -{ - struct mmc_gpio *ctx = host->slot.handler_priv; - int ret; - - if (!gpio_is_valid(gpio)) - return -EINVAL; - - ret = devm_gpio_request_one(host->parent, gpio, GPIOF_DIR_IN, - ctx->ro_label); - if (ret < 0) - return ret; - - ctx->override_ro_active_level = true; - ctx->ro_gpio = gpio_to_desc(gpio); - - return 0; -} -EXPORT_SYMBOL(mmc_gpio_request_ro); - void mmc_gpiod_request_cd_irq(struct mmc_host *host) { struct mmc_gpio *ctx = host->slot.handler_priv; @@ -200,50 +169,6 @@ void mmc_gpio_set_cd_isr(struct mmc_host *host, } EXPORT_SYMBOL(mmc_gpio_set_cd_isr); -/** - * mmc_gpio_request_cd - request a gpio for card-detection - * @host: mmc host - * @gpio: gpio number requested - * @debounce: debounce time in microseconds - * - * As devm_* managed functions are used in mmc_gpio_request_cd(), client - * drivers do not need to worry about freeing up memory. - * - * If GPIO debouncing is desired, set the debounce parameter to a non-zero - * value. The caller is responsible for ensuring that the GPIO driver associated - * with the GPIO supports debouncing, otherwise an error will be returned. - * - * Returns zero on success, else an error. - */ -int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio, - unsigned int debounce) -{ - struct mmc_gpio *ctx = host->slot.handler_priv; - int ret; - - ret = devm_gpio_request_one(host->parent, gpio, GPIOF_DIR_IN, - ctx->cd_label); - if (ret < 0) - /* - * don't bother freeing memory. It might still get used by other - * slot functions, in any case it will be freed, when the device - * is destroyed. - */ - return ret; - - if (debounce) { - ret = gpio_set_debounce(gpio, debounce); - if (ret < 0) - return ret; - } - - ctx->override_cd_active_level = true; - ctx->cd_gpio = gpio_to_desc(gpio); - - return 0; -} -EXPORT_SYMBOL(mmc_gpio_request_cd); - /** * mmc_gpiod_request_cd - request a gpio descriptor for card-detection * @host: mmc host @@ -254,8 +179,7 @@ EXPORT_SYMBOL(mmc_gpio_request_cd); * @gpio_invert: will return whether the GPIO line is inverted or not, set * to NULL to ignore * - * Use this function in place of mmc_gpio_request_cd() to use the GPIO - * descriptor API. Note that it must be called prior to mmc_add_host() + * Note that this must be called prior to mmc_add_host() * otherwise the caller must also call mmc_gpiod_request_cd_irq(). * * Returns zero on success, else an error. @@ -306,9 +230,6 @@ EXPORT_SYMBOL(mmc_can_gpio_cd); * @gpio_invert: will return whether the GPIO line is inverted or not, * set to NULL to ignore * - * Use this function in place of mmc_gpio_request_ro() to use the GPIO - * descriptor API. - * * Returns zero on success, else an error. */ int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id, diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h index 06607c59c4d0..feebd7aa6f5c 100644 --- a/include/linux/mmc/slot-gpio.h +++ b/include/linux/mmc/slot-gpio.h @@ -17,12 +17,7 @@ struct mmc_host; int mmc_gpio_get_ro(struct mmc_host *host); -int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio); - int mmc_gpio_get_cd(struct mmc_host *host); -int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio, - unsigned int debounce); - int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, unsigned int idx, bool override_active_level, unsigned int debounce, bool *gpio_invert);