From patchwork Sun Nov 25 22:52:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151934 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4908804ljp; Sun, 25 Nov 2018 14:54:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/UylbGgnvyQEPez6uiTa3t88FHodf6AH+caaArx8MFoBmGjGqobqcAYOn5qC0axt8ODC9Wd X-Received: by 2002:a62:e90a:: with SMTP id j10-v6mr5765542pfh.228.1543186483104; Sun, 25 Nov 2018 14:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543186483; cv=none; d=google.com; s=arc-20160816; b=X0EovHOIZ+CxmYLDUuBZM/B17XTgf2lpP14Awnj8oXXeG4/qQSEpMLk/Bh+C4DjbL8 +fbY00aCgVwTqRI+clQmu9gHZnQVDzD6ROFxeU0gNxQozlMRj3JGETWuJLMuDbBUBQxI STWkTw4aiRuCySNpd7fxvGfUnSj1iJd0AKqaR5TS2nL7HMWboBOwHh2BMFatlUfXzj0G njgacjDJpDfoaYR9HYo59REgz25FplTiJm7XausHVy5EsH6iSnFLWoxHaLKACgcEH6kK tVlMZTcecZSdkoYUb00G0lcWEkuRULfoKsqLmDS+1r9zGeQ2DrqKKXbMX9Y6bgEg3+j4 Y1vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fB+xFxOzFXu5MoyKR1JSlSbMyC12Dayzv8qa+PTbeb8=; b=oRMvpILOCsZK+pum4j0IKxSSzTvuhR3Rm2TB0b2CC6KJut/bltWafUDxnk7fM3PqG5 pAGNnm9Eyjdn6lrw3tff0ROOSUyTuSHiLnemrB8q4FLhydf+FgEhC40jKWCB3CyTsPFh GIJinUcyekjZaAvnvcbsKZn0J8zQNboIXGDN6xKHTZdA8inFtXeIAhrtcuvqKavUbfRU kiXvYJjAGLUBiXwF1wLhgr9ZKvytmoopnCWaE/ShOlf94KUUhoQ8cCnfCOFe4S0sPx6G iKUFsj9SbxiQr3dED8Wx/dBpjCaxY+pjxIMzqf6J9+YUUPtC1wO44l8BhyMOx3QOrtth jBzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VVzPsHJO; 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 m75si39838955pga.432.2018.11.25.14.54.42; Sun, 25 Nov 2018 14:54:43 -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=VVzPsHJO; 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 S1726085AbeKZJqx (ORCPT + 5 others); Mon, 26 Nov 2018 04:46:53 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:32853 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbeKZJqx (ORCPT ); Mon, 26 Nov 2018 04:46:53 -0500 Received: by mail-lj1-f195.google.com with SMTP id v1-v6so14855696ljd.0 for ; Sun, 25 Nov 2018 14:54:40 -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 :mime-version:content-transfer-encoding; bh=fB+xFxOzFXu5MoyKR1JSlSbMyC12Dayzv8qa+PTbeb8=; b=VVzPsHJOLqJPYEz30/7UHEWq2x53K9GG83m9bF0tnDOYOatfKogj2a5tUwsTsvHYbt NODCHUM+lwSme42gexmQPcnUWerJfHcSJWZsYaiT5hK3wzrQPi1CUZm7N6GljZ7EPOx6 lwZ6JRKnypmoA4mYez3r8nRnK9whCdl1FM0es= 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:mime-version:content-transfer-encoding; bh=fB+xFxOzFXu5MoyKR1JSlSbMyC12Dayzv8qa+PTbeb8=; b=pTMt9qoFREGqy5nPVqzeUBm5K5E5PyOK549cWl5z517OMSWTl9njXQ7k0SetN4npeF ++SXIMxzi6WVo4ln4PznrvrRJ+8rOhKSUvOm34JVZTvt2bds45L9vjvkeubNv0ie1rmb vkLK/pLenCq21R/JAMBCDFrOTUhQakC8phqPbkmLGb5eLeysP5NlnET7Qxui/hsVKjoQ Ua+jiwbQoXIMhFb0rAY1NPDH/hLf+TrlkuwQO4i+zNSkq0M746e7FwwMy5FXldkZOLyo xDVHxlEMyYrhtA4Hs/rofqj9g9BAdetpvD37mDqvUkFe2hrEzmh4kqxiEybMc4N6MMCO Dj2w== X-Gm-Message-State: AA+aEWa3cP/2v277tloijbHTKqI8jpAcPMjJ0tKdUczS6BS0WMnFsuDt UI2FRUn9yOlj89kK220YWhc7ALai2zRMWA== X-Received: by 2002:a2e:9556:: with SMTP id t22-v6mr9489695ljh.36.1543186478605; Sun, 25 Nov 2018 14:54:38 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id c19sm9047235lfg.86.2018.11.25.14.54.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Nov 2018 14:54:37 -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 03/11 v3] mmc: s3cmci: Use the slot GPIO descriptor Date: Sun, 25 Nov 2018 23:52:09 +0100 Message-Id: <20181125225217.23201-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181125225217.23201-1-linus.walleij@linaro.org> References: <20181125225217.23201-1-linus.walleij@linaro.org> MIME-Version: 1.0 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 --- ChangeLog v2->v3: - Fix the missed write protect inversion on mini2440 so restored the ability to pass this flag to the core. Also adding the ACTIVE_HIGH flag to the GPIO in the lookup table so the polarity will be correct in the descriptor even if we are not using it yet. - Keep the snippet dropping the card detect inversion flag as no host was using that. ChangeLog v1->v2: - Fix erroneous gpiochip labels "GPIOG" to just "GPG" etc. 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 | 15 ++++++++++-- arch/arm/mach-s3c24xx/mach-n30.c | 15 ++++++++++-- arch/arm/mach-s3c24xx/mach-rx1950.c | 15 ++++++++++-- drivers/mmc/host/s3cmci.c | 29 +++++++++--------------- include/linux/platform_data/mmc-s3cmci.h | 4 ---- 7 files changed, 75 insertions(+), 32 deletions(-) -- 2.19.1 Reviewed-by: Krzysztof Kozlowski diff --git a/arch/arm/mach-s3c24xx/mach-at2440evb.c b/arch/arm/mach-s3c24xx/mach-at2440evb.c index 68a4fa94257a..58c5ef3cf1d7 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("GPG", 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..74d6b68e91c7 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("GPF", 5, "cd", GPIO_ACTIVE_LOW), + /* Write protect S3C2410_GPH(8) */ + GPIO_LOOKUP("GPH", 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..9035f868fb34 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,22 @@ 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("GPG", 8, "cd", GPIO_ACTIVE_LOW), + /* Write protect S3C2410_GPH(8) */ + GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* NAND Flash on MINI2440 board */ static struct mtd_partition mini2440_default_nand_part[] __initdata = { @@ -696,6 +706,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..d856f23939af 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("GPF", 1, "cd", GPIO_ACTIVE_LOW), + /* Write protect S3C2410_GPG(10) */ + GPIO_LOOKUP("GPG", 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..29f9b345a531 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("GPF", 5, "cd", GPIO_ACTIVE_LOW), + /* Write protect S3C2410_GPH(8) */ + GPIO_LOOKUP("GPH", 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..e1811ffd7b70 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -1545,25 +1544,19 @@ static int s3cmci_probe_pdata(struct s3cmci_host *host) 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..33310b11cbdd 100644 --- a/include/linux/platform_data/mmc-s3cmci.h +++ b/include/linux/platform_data/mmc-s3cmci.h @@ -7,7 +7,6 @@ * @no_wprotect: Set this to indicate there is no write-protect switch. * @no_detect: Set this if there is no detect switch. * @wprotect_invert: Invert the default sense of the write protect switch. - * @detect_invert: Invert the default sense of the write protect switch. * @use_dma: Set to allow the use of DMA. * @gpio_detect: GPIO number for the card detect line. * @gpio_wprotect: GPIO number for the write protect line. @@ -31,11 +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);