From d12e276cb04717013ab243bbb37360ed6f456e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Wed, 20 Jul 2016 12:58:51 +0200 Subject: kernel: backport patch for MTD_BCM47XXSFLASH dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is required to update bcma without build breakage. One of bcma patches changes BCMA_SFLASH dependency. Signed-off-by: Rafał Miłecki --- ...sflash-use-ioremap_cache-instead-of-KSEG0.patch | 138 +++++++++++++++++++++ ...h-dependency-for-MTD_BCM47XXSFLASH-symbol.patch | 41 ++++++ ...sflash-use-ioremap_cache-instead-of-KSEG0.patch | 138 --------------------- 3 files changed, 179 insertions(+), 138 deletions(-) create mode 100644 target/linux/generic/patches-4.4/042-0001-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch create mode 100644 target/linux/generic/patches-4.4/042-0002-mtd-add-arch-dependency-for-MTD_BCM47XXSFLASH-symbol.patch delete mode 100644 target/linux/generic/patches-4.4/042-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch diff --git a/target/linux/generic/patches-4.4/042-0001-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch b/target/linux/generic/patches-4.4/042-0001-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch new file mode 100644 index 0000000000..a401e55b44 --- /dev/null +++ b/target/linux/generic/patches-4.4/042-0001-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch @@ -0,0 +1,138 @@ +From 5651d6aaf489d1db48c253cf884b40214e91c2c5 Mon Sep 17 00:00:00 2001 +From: Brian Norris +Date: Fri, 26 Feb 2016 11:50:28 +0100 +Subject: [PATCH] mtd: bcm47xxsflash: use ioremap_cache() instead of + KSEG0ADDR() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Using KSEG0ADDR makes code highly MIPS dependent and not portable. +Thanks to the fix a68f376 ("MIPS: io.h: Define `ioremap_cache'") we can +use ioremap_cache which is generic and supported on MIPS as well now. + +KSEG0ADDR was translating 0x1c000000 into 0x9c000000. With ioremap_cache +we use MIPS's __ioremap (and then remap_area_pages). This results in +different address (e.g. 0xc0080000) but it still should be cached as +expected and it was successfully tested with BCM47186B0. + +Other than that drivers/bcma/driver_chipcommon_sflash.c nicely setups a +struct resource for access window, but we wren't using it. Use it now +and drop duplicated info. + +Signed-off-by: Brian Norris +Signed-off-by: Rafał Miłecki +--- + +--- a/drivers/bcma/driver_chipcommon_sflash.c ++++ b/drivers/bcma/driver_chipcommon_sflash.c +@@ -146,7 +146,6 @@ int bcma_sflash_init(struct bcma_drv_cc + return -ENOTSUPP; + } + +- sflash->window = BCMA_SOC_FLASH2; + sflash->blocksize = e->blocksize; + sflash->numblocks = e->numblocks; + sflash->size = sflash->blocksize * sflash->numblocks; +--- a/drivers/mtd/devices/bcm47xxsflash.c ++++ b/drivers/mtd/devices/bcm47xxsflash.c +@@ -2,6 +2,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -109,8 +110,7 @@ static int bcm47xxsflash_read(struct mtd + if ((from + len) > mtd->size) + return -EINVAL; + +- memcpy_fromio(buf, (void __iomem *)KSEG0ADDR(b47s->window + from), +- len); ++ memcpy_fromio(buf, b47s->window + from, len); + *retlen = len; + + return len; +@@ -275,15 +275,33 @@ static void bcm47xxsflash_bcma_cc_write( + + static int bcm47xxsflash_bcma_probe(struct platform_device *pdev) + { +- struct bcma_sflash *sflash = dev_get_platdata(&pdev->dev); ++ struct device *dev = &pdev->dev; ++ struct bcma_sflash *sflash = dev_get_platdata(dev); + struct bcm47xxsflash *b47s; ++ struct resource *res; + int err; + +- b47s = devm_kzalloc(&pdev->dev, sizeof(*b47s), GFP_KERNEL); ++ b47s = devm_kzalloc(dev, sizeof(*b47s), GFP_KERNEL); + if (!b47s) + return -ENOMEM; + sflash->priv = b47s; + ++ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ if (!res) { ++ dev_err(dev, "invalid resource\n"); ++ return -EINVAL; ++ } ++ if (!devm_request_mem_region(dev, res->start, resource_size(res), ++ res->name)) { ++ dev_err(dev, "can't request region for resource %pR\n", res); ++ return -EBUSY; ++ } ++ b47s->window = ioremap_cache(res->start, resource_size(res)); ++ if (!b47s->window) { ++ dev_err(dev, "ioremap failed for resource %pR\n", res); ++ return -ENOMEM; ++ } ++ + b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash); + b47s->cc_read = bcm47xxsflash_bcma_cc_read; + b47s->cc_write = bcm47xxsflash_bcma_cc_write; +@@ -297,7 +315,6 @@ static int bcm47xxsflash_bcma_probe(stru + break; + } + +- b47s->window = sflash->window; + b47s->blocksize = sflash->blocksize; + b47s->numblocks = sflash->numblocks; + b47s->size = sflash->size; +@@ -306,6 +323,7 @@ static int bcm47xxsflash_bcma_probe(stru + err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0); + if (err) { + pr_err("Failed to register MTD device: %d\n", err); ++ iounmap(b47s->window); + return err; + } + +@@ -321,6 +339,7 @@ static int bcm47xxsflash_bcma_remove(str + struct bcm47xxsflash *b47s = sflash->priv; + + mtd_device_unregister(&b47s->mtd); ++ iounmap(b47s->window); + + return 0; + } +--- a/drivers/mtd/devices/bcm47xxsflash.h ++++ b/drivers/mtd/devices/bcm47xxsflash.h +@@ -65,7 +65,8 @@ struct bcm47xxsflash { + + enum bcm47xxsflash_type type; + +- u32 window; ++ void __iomem *window; ++ + u32 blocksize; + u16 numblocks; + u32 size; +--- a/include/linux/bcma/bcma_driver_chipcommon.h ++++ b/include/linux/bcma/bcma_driver_chipcommon.h +@@ -585,7 +585,6 @@ struct bcma_pflash { + #ifdef CONFIG_BCMA_SFLASH + struct bcma_sflash { + bool present; +- u32 window; + u32 blocksize; + u16 numblocks; + u32 size; diff --git a/target/linux/generic/patches-4.4/042-0002-mtd-add-arch-dependency-for-MTD_BCM47XXSFLASH-symbol.patch b/target/linux/generic/patches-4.4/042-0002-mtd-add-arch-dependency-for-MTD_BCM47XXSFLASH-symbol.patch new file mode 100644 index 0000000000..b7ff055ab1 --- /dev/null +++ b/target/linux/generic/patches-4.4/042-0002-mtd-add-arch-dependency-for-MTD_BCM47XXSFLASH-symbol.patch @@ -0,0 +1,41 @@ +From efacc699139e13f9d3ed8b47df92acb88ff8479f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Tue, 19 Jul 2016 09:08:32 +0200 +Subject: [PATCH] mtd: add arch dependency for MTD_BCM47XXSFLASH symbol +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We dropped strict MIPS dependency for bcm47xxsflash driver in: +commit 5651d6aaf489 ("mtd: bcm47xxsflash: use ioremap_cache() instead of +KSEG0ADDR()") but using ioremap_cache still limits building it to few +selected architectures only. + +A recent commit 57d8f7dd2132 ("bcma: allow enabling serial flash support +on non-MIPS SoCs") automatically dropped MIPS dependency for +MTD_BCM47XXSFLASH which broke building e.g. on powerpc and cris. + +The bcma change is alright as it doesn't break building bcma code in any +way. MTD_BCM47XXSFLASH on the other hand should be limited to archs +which need it and can build it (by providing ioremap_cache). + +Fixes: 57d8f7dd2132 ("bcma: allow enabling serial flash support on non-MIPS SoCs") +Signed-off-by: Rafał Miłecki +Cc: Brian Norris +Acked-by: Brian Norris +Signed-off-by: Kalle Valo +--- + drivers/mtd/devices/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/mtd/devices/Kconfig ++++ b/drivers/mtd/devices/Kconfig +@@ -114,7 +114,7 @@ config MTD_SST25L + + config MTD_BCM47XXSFLASH + tristate "R/O support for serial flash on BCMA bus" +- depends on BCMA_SFLASH ++ depends on BCMA_SFLASH && (MIPS || ARM) + help + BCMA bus can have various flash memories attached, they are + registered by bcma as platform devices. This enables driver for diff --git a/target/linux/generic/patches-4.4/042-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch b/target/linux/generic/patches-4.4/042-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch deleted file mode 100644 index a401e55b44..0000000000 --- a/target/linux/generic/patches-4.4/042-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 5651d6aaf489d1db48c253cf884b40214e91c2c5 Mon Sep 17 00:00:00 2001 -From: Brian Norris -Date: Fri, 26 Feb 2016 11:50:28 +0100 -Subject: [PATCH] mtd: bcm47xxsflash: use ioremap_cache() instead of - KSEG0ADDR() -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Using KSEG0ADDR makes code highly MIPS dependent and not portable. -Thanks to the fix a68f376 ("MIPS: io.h: Define `ioremap_cache'") we can -use ioremap_cache which is generic and supported on MIPS as well now. - -KSEG0ADDR was translating 0x1c000000 into 0x9c000000. With ioremap_cache -we use MIPS's __ioremap (and then remap_area_pages). This results in -different address (e.g. 0xc0080000) but it still should be cached as -expected and it was successfully tested with BCM47186B0. - -Other than that drivers/bcma/driver_chipcommon_sflash.c nicely setups a -struct resource for access window, but we wren't using it. Use it now -and drop duplicated info. - -Signed-off-by: Brian Norris -Signed-off-by: Rafał Miłecki ---- - ---- a/drivers/bcma/driver_chipcommon_sflash.c -+++ b/drivers/bcma/driver_chipcommon_sflash.c -@@ -146,7 +146,6 @@ int bcma_sflash_init(struct bcma_drv_cc - return -ENOTSUPP; - } - -- sflash->window = BCMA_SOC_FLASH2; - sflash->blocksize = e->blocksize; - sflash->numblocks = e->numblocks; - sflash->size = sflash->blocksize * sflash->numblocks; ---- a/drivers/mtd/devices/bcm47xxsflash.c -+++ b/drivers/mtd/devices/bcm47xxsflash.c -@@ -2,6 +2,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -109,8 +110,7 @@ static int bcm47xxsflash_read(struct mtd - if ((from + len) > mtd->size) - return -EINVAL; - -- memcpy_fromio(buf, (void __iomem *)KSEG0ADDR(b47s->window + from), -- len); -+ memcpy_fromio(buf, b47s->window + from, len); - *retlen = len; - - return len; -@@ -275,15 +275,33 @@ static void bcm47xxsflash_bcma_cc_write( - - static int bcm47xxsflash_bcma_probe(struct platform_device *pdev) - { -- struct bcma_sflash *sflash = dev_get_platdata(&pdev->dev); -+ struct device *dev = &pdev->dev; -+ struct bcma_sflash *sflash = dev_get_platdata(dev); - struct bcm47xxsflash *b47s; -+ struct resource *res; - int err; - -- b47s = devm_kzalloc(&pdev->dev, sizeof(*b47s), GFP_KERNEL); -+ b47s = devm_kzalloc(dev, sizeof(*b47s), GFP_KERNEL); - if (!b47s) - return -ENOMEM; - sflash->priv = b47s; - -+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -+ if (!res) { -+ dev_err(dev, "invalid resource\n"); -+ return -EINVAL; -+ } -+ if (!devm_request_mem_region(dev, res->start, resource_size(res), -+ res->name)) { -+ dev_err(dev, "can't request region for resource %pR\n", res); -+ return -EBUSY; -+ } -+ b47s->window = ioremap_cache(res->start, resource_size(res)); -+ if (!b47s->window) { -+ dev_err(dev, "ioremap failed for resource %pR\n", res); -+ return -ENOMEM; -+ } -+ - b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash); - b47s->cc_read = bcm47xxsflash_bcma_cc_read; - b47s->cc_write = bcm47xxsflash_bcma_cc_write; -@@ -297,7 +315,6 @@ static int bcm47xxsflash_bcma_probe(stru - break; - } - -- b47s->window = sflash->window; - b47s->blocksize = sflash->blocksize; - b47s->numblocks = sflash->numblocks; - b47s->size = sflash->size; -@@ -306,6 +323,7 @@ static int bcm47xxsflash_bcma_probe(stru - err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0); - if (err) { - pr_err("Failed to register MTD device: %d\n", err); -+ iounmap(b47s->window); - return err; - } - -@@ -321,6 +339,7 @@ static int bcm47xxsflash_bcma_remove(str - struct bcm47xxsflash *b47s = sflash->priv; - - mtd_device_unregister(&b47s->mtd); -+ iounmap(b47s->window); - - return 0; - } ---- a/drivers/mtd/devices/bcm47xxsflash.h -+++ b/drivers/mtd/devices/bcm47xxsflash.h -@@ -65,7 +65,8 @@ struct bcm47xxsflash { - - enum bcm47xxsflash_type type; - -- u32 window; -+ void __iomem *window; -+ - u32 blocksize; - u16 numblocks; - u32 size; ---- a/include/linux/bcma/bcma_driver_chipcommon.h -+++ b/include/linux/bcma/bcma_driver_chipcommon.h -@@ -585,7 +585,6 @@ struct bcma_pflash { - #ifdef CONFIG_BCMA_SFLASH - struct bcma_sflash { - bool present; -- u32 window; - u32 blocksize; - u16 numblocks; - u32 size; -- cgit v1.2.3