From 6f38010d54a9dfd4b9c9e49a7184f84cc2281605 Mon Sep 17 00:00:00 2001 From: Kyoungil Kim Date: Wed, 23 May 2012 21:34:06 +0900 Subject: spi: Keep chipselect assertion during one message During all transfers in one message, the device will not be chagned. So we don't need to deassert chipselect during one message. Signed-off-by: Kyoungil Kim Signed-off-by: Grant Likely diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 4dd7b7c..88c3f5e 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -771,8 +771,6 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, if (list_is_last(&xfer->transfer_list, &msg->transfers)) cs_toggle = 1; - else - disable_cs(sdd, spi); } msg->actual_length += xfer->len; -- cgit v0.10.2 From 7d859ff4937a22aabc0d3f352d1f515fb8b38528 Mon Sep 17 00:00:00 2001 From: Kyoungil Kim Date: Wed, 23 May 2012 21:29:51 +0900 Subject: spi: Change FIFO flush operation and spi channel off Setting SW_RST does TX/RX FIFO flush. After FIFO flush, SW_RST should be cleared. The above setting and clearing SW_RST operation should be done after spi channel off. Signed-off-by: Kyoungil Kim Signed-off-by: Grant Likely diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 88c3f5e..ad93231 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -215,6 +215,10 @@ static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) writel(0, regs + S3C64XX_SPI_PACKET_CNT); val = readl(regs + S3C64XX_SPI_CH_CFG); + val &= ~(S3C64XX_SPI_CH_RXCH_ON | S3C64XX_SPI_CH_TXCH_ON); + writel(val, regs + S3C64XX_SPI_CH_CFG); + + val = readl(regs + S3C64XX_SPI_CH_CFG); val |= S3C64XX_SPI_CH_SW_RST; val &= ~S3C64XX_SPI_CH_HS_EN; writel(val, regs + S3C64XX_SPI_CH_CFG); @@ -248,10 +252,6 @@ static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) val = readl(regs + S3C64XX_SPI_MODE_CFG); val &= ~(S3C64XX_SPI_MODE_TXDMA_ON | S3C64XX_SPI_MODE_RXDMA_ON); writel(val, regs + S3C64XX_SPI_MODE_CFG); - - val = readl(regs + S3C64XX_SPI_CH_CFG); - val &= ~(S3C64XX_SPI_CH_RXCH_ON | S3C64XX_SPI_CH_TXCH_ON); - writel(val, regs + S3C64XX_SPI_CH_CFG); } static void s3c64xx_spi_dmacb(void *data) -- cgit v0.10.2 From cb71941a682270dd5164d1332900694d19caa5e1 Mon Sep 17 00:00:00 2001 From: David Daney Date: Tue, 22 May 2012 15:47:19 -0700 Subject: of/spi: Fix SPI module loading by using proper "spi:" modalias prefixes. To get modprobe to automatically load the proper modules, we need to prefix things with "spi:". Partially based on Grant Likely's suggestions. Signed-off-by: David Daney [grant.likely: reworked because drivers/of/of_spi.c has been removed] Signed-off-by: Grant Likely diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index ab095ac..19ee901 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -824,6 +824,7 @@ static void of_register_spi_devices(struct spi_master *master) struct spi_device *spi; struct device_node *nc; const __be32 *prop; + char modalias[SPI_NAME_SIZE + 4]; int rc; int len; @@ -887,7 +888,9 @@ static void of_register_spi_devices(struct spi_master *master) spi->dev.of_node = nc; /* Register the new device */ - request_module(spi->modalias); + snprintf(modalias, sizeof(modalias), "%s%s", SPI_MODULE_PREFIX, + spi->modalias); + request_module(modalias); rc = spi_add_device(spi); if (rc) { dev_err(&master->dev, "spi_device register error %s\n", -- cgit v0.10.2 From 850a5b670af6293fcb1852af57567d19150ff638 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Fri, 23 Nov 2012 13:44:39 +0100 Subject: spi/atmel: add DT support Use the newly introduce cs-gpios dt support on atmel. We do not use the hardware cs as it's wired and has bugs and limitations. As the controller believes that only active-low devices/systems exists. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Acked-by: Nicolas Ferre Signed-off-by: Grant Likely diff --git a/Documentation/devicetree/bindings/spi/spi_atmel.txt b/Documentation/devicetree/bindings/spi/spi_atmel.txt new file mode 100644 index 0000000..07e04cd --- /dev/null +++ b/Documentation/devicetree/bindings/spi/spi_atmel.txt @@ -0,0 +1,26 @@ +Atmel SPI device + +Required properties: +- compatible : should be "atmel,at91rm9200-spi". +- reg: Address and length of the register set for the device +- interrupts: Should contain spi interrupt +- cs-gpios: chipselects + +Example: + +spi1: spi@fffcc000 { + compatible = "atmel,at91rm9200-spi"; + reg = <0xfffcc000 0x4000>; + interrupts = <13 4 5>; + #address-cells = <1>; + #size-cells = <0>; + cs-gpios = <&pioB 3 0>; + status = "okay"; + + mmc-slot@0 { + compatible = "mmc-spi-slot"; + reg = <0>; + gpios = <&pioC 4 0>; /* CD */ + spi-max-frequency = <25000000>; + }; +}; diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 75c0c4f..ab34497 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -768,6 +769,10 @@ static int atmel_spi_setup(struct spi_device *spi) /* chipselect must have been muxed as GPIO (e.g. in board setup) */ npcs_pin = (unsigned int)spi->controller_data; + + if (gpio_is_valid(spi->cs_gpio)) + npcs_pin = spi->cs_gpio; + asd = spi->controller_state; if (!asd) { asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL); @@ -937,8 +942,9 @@ static int atmel_spi_probe(struct platform_device *pdev) /* the spi->mode bits understood by this driver: */ master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; + master->dev.of_node = pdev->dev.of_node; master->bus_num = pdev->id; - master->num_chipselect = 4; + master->num_chipselect = master->dev.of_node ? 0 : 4; master->setup = atmel_spi_setup; master->transfer = atmel_spi_transfer; master->cleanup = atmel_spi_cleanup; @@ -1064,11 +1070,20 @@ static int atmel_spi_resume(struct platform_device *pdev) #define atmel_spi_resume NULL #endif +#if defined(CONFIG_OF) +static const struct of_device_id atmel_spi_dt_ids[] = { + { .compatible = "atmel,at91rm9200-spi" }, + { /* sentinel */ } +}; + +MODULE_DEVICE_TABLE(of, atmel_spi_dt_ids); +#endif static struct platform_driver atmel_spi_driver = { .driver = { .name = "atmel_spi", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(atmel_spi_dt_ids), }, .suspend = atmel_spi_suspend, .resume = atmel_spi_resume, -- cgit v0.10.2 From 80c2022e5645a1a789531d13010292c5c18bf1db Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Wed, 19 Dec 2012 10:45:36 +0000 Subject: of: Fix export of of_find_matching_node_and_match() Commit 50c8af4cf9, "of: introduce for_each_matching_node_and_match()" renamed of_find_matching_node() to of_find_matching_node_and_match() and created a new static inline of_find_matching_node() wrapper around the new name. However, the change neglected to change the EXPORT_SYMBOL() reference causing build errors for modules. This patch fixes the EXPORT_SYMBOL() statement. Discovered on a PowerPC Efika build with the mpc52xx_uart driver being built as a module. Reported-by: Benjamin Herrenschmidt Signed-off-by: Grant Likely diff --git a/drivers/of/base.c b/drivers/of/base.c index db8d211..2390ddb 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -629,7 +629,7 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from, read_unlock(&devtree_lock); return np; } -EXPORT_SYMBOL(of_find_matching_node); +EXPORT_SYMBOL(of_find_matching_node_and_match); /** * of_modalias_node - Lookup appropriate modalias for a device node -- cgit v0.10.2 From 6a79131318dd6f71ec46e0af1daa581e695fd5ab Mon Sep 17 00:00:00 2001 From: Allen Martin Date: Fri, 14 Dec 2012 11:05:12 -0800 Subject: spi: fix tegra SPI binding examples Fix name of slink binding and address of sflash example to make it self consistent. Signed-off-by: Allen Martin Signed-off-by: Grant Likely diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt b/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt index 8cf24f6..7b53da5 100644 --- a/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt +++ b/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt @@ -13,7 +13,7 @@ Recommended properties: Example: -spi@7000d600 { +spi@7000c380 { compatible = "nvidia,tegra20-sflash"; reg = <0x7000c380 0x80>; interrupts = <0 39 0x04>; diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt b/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt index f5b1ad1..eefe15e 100644 --- a/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt +++ b/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt @@ -13,7 +13,7 @@ Recommended properties: Example: -slink@7000d600 { +spi@7000d600 { compatible = "nvidia,tegra20-slink"; reg = <0x7000d600 0x200>; interrupts = <0 82 0x04>; -- cgit v0.10.2 From d3601e56cf64a3f2df6f6380cccb3644274406e2 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Wed, 12 Dec 2012 01:24:54 +0100 Subject: spi/sh-hspi: fix return value check in hspi_probe(). According to its documentation, clk_get() returns a "valid IS_ERR() condition containing errno", so we should call IS_ERR() rather than a NULL check. Signed-off-by: Cyril Roelandt Acked-by: Kuninori Morimoto Signed-off-by: Grant Likely diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c index 32f7b55..60cfae5 100644 --- a/drivers/spi/spi-sh-hspi.c +++ b/drivers/spi/spi-sh-hspi.c @@ -290,7 +290,7 @@ static int hspi_probe(struct platform_device *pdev) } clk = clk_get(NULL, "shyway_clk"); - if (!clk) { + if (IS_ERR(clk)) { dev_err(&pdev->dev, "shyway_clk is required\n"); ret = -EINVAL; goto error0; -- cgit v0.10.2 From ab28698d33af05abab0bcf8021eafe38f7434f24 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Wed, 19 Dec 2012 09:10:09 -0600 Subject: of: define struct device in of_platform.h if !OF_DEVICE and !OF_ADDRESS Fixes the following warning: include/linux/of_platform.h:106:13: warning: 'struct device' declared inside parameter list [enabled by default] include/linux/of_platform.h:106:13: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] Signed-off-by: Jonas Gorski Signed-off-by: Rob Herring Signed-off-by: Grant Likely diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index b47d204..3863a4d 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -100,6 +100,7 @@ extern int of_platform_populate(struct device_node *root, #if !defined(CONFIG_OF_ADDRESS) struct of_dev_auxdata; +struct device; static inline int of_platform_populate(struct device_node *root, const struct of_device_id *matches, const struct of_dev_auxdata *lookup, -- cgit v0.10.2 From d39a948fef2446cfac3749bbfcfdd536335c3764 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 16 Dec 2012 21:31:40 +0100 Subject: gpio/ich: Add missing spinlock init As reported by CONFIG_DEBUG_SPINLOCK=y. Signed-off-by: Jean Delvare Acked-by: Peter Tyser Signed-off-by: Grant Likely diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c index 6cc87ac..6f2306d 100644 --- a/drivers/gpio/gpio-ich.c +++ b/drivers/gpio/gpio-ich.c @@ -390,6 +390,7 @@ static int ichx_gpio_probe(struct platform_device *pdev) return -ENODEV; } + spin_lock_init(&ichx_priv.lock); res_base = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_GPIO); ichx_priv.use_gpio = ich_info->use_gpio; err = ichx_gpio_request_regions(res_base, pdev->name, -- cgit v0.10.2 From bc1008cf7d243cf6ad87b1e16d3dbbd8c8d6f35c Mon Sep 17 00:00:00 2001 From: Gregory CLEMENT Date: Wed, 19 Dec 2012 12:31:11 +0100 Subject: gpio/mvebu-gpio: Make mvebu-gpio depend on OF_CONFIG When building without device tree support (for the mv78x00 SoCs for example), the build failed because of_irq_count is undeclared. However mvebu-gpio is not designed to build without device tree support. So make it depends on OF_CONFIG, remove the #ifdef OF_CONFIG line and the platform_device_id. Tested on RD-78x00-mASA, DB-78460-BP, DB-88F6710-BP-DDR3, DB-MV784MP-GP, Mirabox and OpenBlocks AX3. Signed-off-by: Gregory CLEMENT Signed-off-by: Grant Likely diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 8ae1f5b..682de75 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -172,6 +172,7 @@ config GPIO_MSM_V2 config GPIO_MVEBU def_bool y depends on PLAT_ORION + depends on OF select GPIO_GENERIC select GENERIC_IRQ_CHIP diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index d767b53..7d9bd94 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -41,7 +41,6 @@ #include #include #include -#include #include /* @@ -469,19 +468,6 @@ static void mvebu_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) } } -static struct platform_device_id mvebu_gpio_ids[] = { - { - .name = "orion-gpio", - }, { - .name = "mv78200-gpio", - }, { - .name = "armadaxp-gpio", - }, { - /* sentinel */ - }, -}; -MODULE_DEVICE_TABLE(platform, mvebu_gpio_ids); - static struct of_device_id mvebu_gpio_of_match[] = { { .compatible = "marvell,orion-gpio", @@ -555,9 +541,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) mvchip->chip.base = id * MVEBU_MAX_GPIO_PER_BANK; mvchip->chip.ngpio = ngpios; mvchip->chip.can_sleep = 0; -#ifdef CONFIG_OF mvchip->chip.of_node = np; -#endif spin_lock_init(&mvchip->lock); mvchip->membase = devm_request_and_ioremap(&pdev->dev, res); @@ -698,7 +682,6 @@ static struct platform_driver mvebu_gpio_driver = { .of_match_table = mvebu_gpio_of_match, }, .probe = mvebu_gpio_probe, - .id_table = mvebu_gpio_ids, }; static int __init mvebu_gpio_init(void) -- cgit v0.10.2