From 64ac43e6fa283f556f0a8f69ad52d6e7d550307d Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Mon, 15 May 2017 11:24:25 +0200 Subject: gpio: mcp23s08: move to pinctrl This moves the mcp23s08 driver from gpio to pinctrl. Actual pinctrl support for configuration of the pull-up resistors follows in its own patch. Signed-off-by: Sebastian Reichel Acked-by: Sylvain Lemieux Signed-off-by: Linus Walleij --- arch/blackfin/configs/BF609-EZKIT_defconfig | 2 +- arch/blackfin/mach-bf527/boards/tll6527m.c | 4 ++-- arch/blackfin/mach-bf609/boards/ezkit.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'arch/blackfin') diff --git a/arch/blackfin/configs/BF609-EZKIT_defconfig b/arch/blackfin/configs/BF609-EZKIT_defconfig index ba4267f658af..3ce77f07208a 100644 --- a/arch/blackfin/configs/BF609-EZKIT_defconfig +++ b/arch/blackfin/configs/BF609-EZKIT_defconfig @@ -105,7 +105,7 @@ CONFIG_SPI=y CONFIG_SPI_ADI_V3=y CONFIG_GPIOLIB=y CONFIG_GPIO_SYSFS=y -CONFIG_GPIO_MCP23S08=y +CONFIG_PINCTRL_MCP23S08=y # CONFIG_HWMON is not set CONFIG_WATCHDOG=y CONFIG_BFIN_WDT=y diff --git a/arch/blackfin/mach-bf527/boards/tll6527m.c b/arch/blackfin/mach-bf527/boards/tll6527m.c index c1acce4c2e45..be61477826f3 100644 --- a/arch/blackfin/mach-bf527/boards/tll6527m.c +++ b/arch/blackfin/mach-bf527/boards/tll6527m.c @@ -348,7 +348,7 @@ static struct platform_device bfin_i2s = { }; #endif -#if IS_ENABLED(CONFIG_GPIO_MCP23S08) +#if IS_ENABLED(CONFIG_PINCTRL_MCP23S08) #include static const struct mcp23s08_platform_data bfin_mcp23s08_sys_gpio_info = { .chip[0].is_present = true, @@ -423,7 +423,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { .mode = SPI_CPHA | SPI_CPOL, }, #endif -#if IS_ENABLED(CONFIG_GPIO_MCP23S08) +#if IS_ENABLED(CONFIG_PINCTRL_MCP23S08) { .modalias = "mcp23s08", .platform_data = &bfin_mcp23s08_sys_gpio_info, diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c index 9231e5a72b93..51157a255824 100644 --- a/arch/blackfin/mach-bf609/boards/ezkit.c +++ b/arch/blackfin/mach-bf609/boards/ezkit.c @@ -1887,7 +1887,7 @@ static struct platform_device i2c_bfin_twi1_device = { }; #endif -#if IS_ENABLED(CONFIG_GPIO_MCP23S08) +#if IS_ENABLED(CONFIG_PINCTRL_MCP23S08) #include static const struct mcp23s08_platform_data bfin_mcp23s08_soft_switch0 = { .base = 120, @@ -1929,7 +1929,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info0[] = { I2C_BOARD_INFO("ssm2602", 0x1b), }, #endif -#if IS_ENABLED(CONFIG_GPIO_MCP23S08) +#if IS_ENABLED(CONFIG_PINCTRL_MCP23S08) { I2C_BOARD_INFO("mcp23017", 0x21), .platform_data = (void *)&bfin_mcp23s08_soft_switch0 -- cgit v1.2.3 From ce9bd0a0ff106b478012dc2e4c2b10bb0138dd7a Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Mon, 15 May 2017 11:24:36 +0200 Subject: pinctrl: mcp23s08: simplify spi_present_mask handling Signed-off-by: Sebastian Reichel Signed-off-by: Linus Walleij --- arch/blackfin/mach-bf527/boards/tll6527m.c | 4 ++-- drivers/pinctrl/pinctrl-mcp23s08.c | 29 ++++++++++------------------- include/linux/spi/mcp23s08.h | 6 +----- 3 files changed, 13 insertions(+), 26 deletions(-) (limited to 'arch/blackfin') diff --git a/arch/blackfin/mach-bf527/boards/tll6527m.c b/arch/blackfin/mach-bf527/boards/tll6527m.c index be61477826f3..ce5488e8226b 100644 --- a/arch/blackfin/mach-bf527/boards/tll6527m.c +++ b/arch/blackfin/mach-bf527/boards/tll6527m.c @@ -351,11 +351,11 @@ static struct platform_device bfin_i2s = { #if IS_ENABLED(CONFIG_PINCTRL_MCP23S08) #include static const struct mcp23s08_platform_data bfin_mcp23s08_sys_gpio_info = { - .chip[0].is_present = true, + .spi_present_mask = BIT(0), .base = 0x30, }; static const struct mcp23s08_platform_data bfin_mcp23s08_usr_gpio_info = { - .chip[2].is_present = true, + .spi_present_mask = BIT(2), .base = 0x38, }; #endif diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index b39da587f2fa..29d9c1fd4309 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -36,6 +36,8 @@ #define MCP_TYPE_017 3 #define MCP_TYPE_S18 4 +#define MCP_MAX_DEV_PER_CS 8 + /* Registers are all 8 bits wide. * * The mcp23s17 has twice as many bits, and can be configured to work @@ -1064,7 +1066,6 @@ static int mcp23s08_probe(struct spi_device *spi) int status, type; unsigned ngpio = 0; const struct of_device_id *match; - u32 spi_present_mask = 0; match = of_match_device(of_match_ptr(mcp23s08_spi_of_match), &spi->dev); if (match) @@ -1078,36 +1079,26 @@ static int mcp23s08_probe(struct spi_device *spi) pdata->base = -1; status = device_property_read_u32(&spi->dev, - "microchip,spi-present-mask", &spi_present_mask); + "microchip,spi-present-mask", &pdata->spi_present_mask); if (status) { status = device_property_read_u32(&spi->dev, - "mcp,spi-present-mask", &spi_present_mask); + "mcp,spi-present-mask", + &pdata->spi_present_mask); if (status) { dev_err(&spi->dev, "missing spi-present-mask"); return -ENODEV; } } - } else { - for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) { - if (!pdata->chip[addr].is_present) - continue; - if ((type == MCP_TYPE_S08) && (addr > 3)) { - dev_err(&spi->dev, - "mcp23s08 only supports address 0..3"); - return -EINVAL; - } - spi_present_mask |= BIT(addr); - } } - if (!spi_present_mask || spi_present_mask >= 256) { + if (!pdata->spi_present_mask || pdata->spi_present_mask > 0xff) { dev_err(&spi->dev, "invalid spi-present-mask"); return -ENODEV; } - for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) { - if (spi_present_mask & BIT(addr)) + for (addr = 0; addr < MCP_MAX_DEV_PER_CS; addr++) { + if (pdata->spi_present_mask & BIT(addr)) chips++; } @@ -1122,8 +1113,8 @@ static int mcp23s08_probe(struct spi_device *spi) spi_set_drvdata(spi, data); - for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) { - if (!(spi_present_mask & (1 << addr))) + for (addr = 0; addr < MCP_MAX_DEV_PER_CS; addr++) { + if (!(pdata->spi_present_mask & BIT(addr))) continue; chips--; data->mcp[addr] = &data->chip[chips]; diff --git a/include/linux/spi/mcp23s08.h b/include/linux/spi/mcp23s08.h index 4af82ee63329..211f3c0ef49c 100644 --- a/include/linux/spi/mcp23s08.h +++ b/include/linux/spi/mcp23s08.h @@ -1,10 +1,6 @@ /* FIXME driver should be able to handle IRQs... */ -struct mcp23s08_chip_info { - bool is_present; /* true if populated */ -}; - struct mcp23s08_platform_data { /* For mcp23s08, up to 4 slaves (numbered 0..3) can share one SPI * chipselect, each providing 1 gpio_chip instance with 8 gpios. @@ -12,7 +8,7 @@ struct mcp23s08_platform_data { * chipselect, each providing 1 gpio_chip (port A + port B) with * 16 gpios. */ - struct mcp23s08_chip_info chip[8]; + u32 spi_present_mask; /* "base" is the number of the first GPIO. Dynamic assignment is * not currently supported, and even if there are gaps in chip -- cgit v1.2.3