From dff3da0091f9943cf34b886df26d7abc624e73ed Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Fri, 13 Oct 2017 14:16:15 +0100 Subject: [PATCH] RPi: update linux support patch for linux 4.13.3 --- .../patches/linux/linux-01-RPi_support.patch | 14166 ++++------------ 1 file changed, 3465 insertions(+), 10701 deletions(-) diff --git a/projects/RPi/patches/linux/linux-01-RPi_support.patch b/projects/RPi/patches/linux/linux-01-RPi_support.patch index 116f117051..83e925c470 100644 --- a/projects/RPi/patches/linux/linux-01-RPi_support.patch +++ b/projects/RPi/patches/linux/linux-01-RPi_support.patch @@ -1,7 +1,7 @@ -From a7c5f5699622a8a86f10f0f87e6e0dbe8b12e95b Mon Sep 17 00:00:00 2001 +From 88902a722552e30b8d6249e486eda1ff04fdfa1f Mon Sep 17 00:00:00 2001 From: Steve Glendinning Date: Thu, 19 Feb 2015 18:47:12 +0000 -Subject: [PATCH 001/199] smsx95xx: fix crimes against truesize +Subject: [PATCH 001/129] smsx95xx: fix crimes against truesize smsc95xx is adjusting truesize when it shouldn't, and following a recent patch from Eric this is now triggering warnings. @@ -48,10 +48,10 @@ index 340c13484e5cc7dd5001577b7522d5a4318bd5b6..7d3d98f0405ad948f9ab3e035a70e15c usbnet_skb_return(dev, ax_skb); } -From ea7f95f7fa5cb7d80d31193627d90c2c9e6ae2dd Mon Sep 17 00:00:00 2001 +From ade4a8cacbaefcb895d993c9381aaeeeee31e673 Mon Sep 17 00:00:00 2001 From: Sam Nazarko Date: Fri, 1 Apr 2016 17:27:21 +0100 -Subject: [PATCH 002/199] smsc95xx: Experimental: Enable turbo_mode and +Subject: [PATCH 002/129] smsc95xx: Experimental: Enable turbo_mode and packetsize=2560 by default See: http://forum.kodi.tv/showthread.php?tid=285288 @@ -94,10 +94,10 @@ index 7d3d98f0405ad948f9ab3e035a70e15c667e4fa1..8d34e517db08d895e6135f785c42bf63 netif_dbg(dev, ifup, dev->net, "rx_urb_size=%ld\n", -From bc924f85dbfd18b8858261b9a3eab89e1300fb10 Mon Sep 17 00:00:00 2001 +From 25192933d19d59a14f37215e2ddbb90579503fa6 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Tue, 26 Mar 2013 17:26:38 +0000 -Subject: [PATCH 003/199] Allow mac address to be set in smsc95xx +Subject: [PATCH 003/129] Allow mac address to be set in smsc95xx Signed-off-by: popcornmix --- @@ -193,10 +193,10 @@ index 8d34e517db08d895e6135f785c42bf639671815c..5df7e105c41532c3185e46ee54f43a37 eth_hw_addr_random(dev->net); netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n"); -From e809a3bc30bf7cc26016141f5d67b1cae9842475 Mon Sep 17 00:00:00 2001 +From d500d2894205e2337ed233cf3e8dfad496ebfe21 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Fri, 13 Mar 2015 12:43:36 +0000 -Subject: [PATCH 004/199] Protect __release_resource against resources without +Subject: [PATCH 004/129] Protect __release_resource against resources without parents Without this patch, removing a device tree overlay can crash here. @@ -224,10 +224,10 @@ index 9b5f04404152c296af3a96132f27cfc80ffa9af9..f8a9af6e6b915812be2ba2c1c2b40106 for (;;) { tmp = *p; -From e6c6e7fd1e6ea6e6f69567ab389987f5de19ca79 Mon Sep 17 00:00:00 2001 +From 033e8448f979a939698a76dd416690bee818fb5f Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Fri, 4 Dec 2015 17:41:50 +0000 -Subject: [PATCH 005/199] irq-bcm2836: Prevent spurious interrupts, and trap +Subject: [PATCH 005/129] irq-bcm2836: Prevent spurious interrupts, and trap them early The old arch-specific IRQ macros included a dsb to ensure the @@ -254,10 +254,10 @@ index e7463e3c08143acae3e8cc5682f918c6a0b07ebd..a8db33b50ad9ff83d284fa54fe4d3b65 #endif } else if (stat) { -From 1a23f9f8acf1fb845d4e36ab74d65b82f1be0ab3 Mon Sep 17 00:00:00 2001 +From a07bbe09f1c828d00b67d894c6892271c26e1b4f Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 9 Feb 2017 14:33:30 +0000 -Subject: [PATCH 006/199] irq-bcm2836: Avoid "Invalid trigger warning" +Subject: [PATCH 006/129] irq-bcm2836: Avoid "Invalid trigger warning" Initialise the level for each IRQ to avoid a warning from the arm arch timer code. @@ -281,10 +281,10 @@ index a8db33b50ad9ff83d284fa54fe4d3b65f859df0f..c4e151451cf8c8ebde5225515eac2786 static void -From 11fdace9d8f093318a1baa563a0fe80cfb7981de Mon Sep 17 00:00:00 2001 +From 112959db13883e0ff2f9523468ae8da2828b2dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Fri, 12 Jun 2015 19:01:05 +0200 -Subject: [PATCH 007/199] irqchip: bcm2835: Add FIQ support +Subject: [PATCH 007/129] irqchip: bcm2835: Add FIQ support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -413,10 +413,10 @@ index 44d7c38dde479d771f3552e914bf8c1c1f5019f7..42ff5e6a8e0d532f5b60a1e7af7cc4d9 } -From 219523948037cd013d47c344b2172bd7c16166aa Mon Sep 17 00:00:00 2001 +From ef67af593f58b62123bbd33bb0cf0f3bc1265e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Fri, 23 Oct 2015 16:26:55 +0200 -Subject: [PATCH 008/199] irqchip: irq-bcm2835: Add 2836 FIQ support +Subject: [PATCH 008/129] irqchip: irq-bcm2835: Add 2836 FIQ support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -515,10 +515,49 @@ index 42ff5e6a8e0d532f5b60a1e7af7cc4d941bd5008..eccf6ed025299cb480884f5bcbe77abf for (b = 0; b < NR_BANKS; b++) { for (i = 0; i < bank_irqs[b]; i++) { -From 3fd120ef50e5b3914008e17f18c4cb59a4c6010f Mon Sep 17 00:00:00 2001 +From c91ea2c42ff1dbdb6d9b753128443a47923616b2 Mon Sep 17 00:00:00 2001 +From: Phil Elwell +Date: Mon, 8 May 2017 16:43:40 +0100 +Subject: [PATCH 009/129] irq_bcm2836: Send event when onlining sleeping cores + +In order to reduce power consumption and bus traffic, it is sensible +for secondary cores to enter a low-power idle state when waiting to +be started. The wfe instruction causes a core to wait until an event +or interrupt arrives before continuing to the next instruction. +The sev instruction sends a wakeup event to the other cores, so call +it from bcm2836_smp_boot_secondary, the function that wakes up the +waiting cores during booting. + +It is harmless to use this patch without the corresponding change +adding wfe to the ARMv7/ARMv8-32 stubs, but if the stubs are updated +and this patch is not applied then the other cores will sleep forever. + +See: https://github.com/raspberrypi/linux/issues/1989 + +Signed-off-by: Phil Elwell +--- + drivers/irqchip/irq-bcm2836.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/irqchip/irq-bcm2836.c b/drivers/irqchip/irq-bcm2836.c +index c4e151451cf8c8ebde5225515eac2786d6f61d46..bee4d2d2ebacc3233423bb9d825e076b9f52fccd 100644 +--- a/drivers/irqchip/irq-bcm2836.c ++++ b/drivers/irqchip/irq-bcm2836.c +@@ -227,6 +227,9 @@ static int __init bcm2836_smp_boot_secondary(unsigned int cpu, + writel(secondary_startup_phys, + intc.base + LOCAL_MAILBOX3_SET0 + 16 * cpu); + ++ dsb(sy); /* Ensure write has completed before waking the other CPUs */ ++ sev(); ++ + return 0; + } + + +From fdfd3d413d68d2ef3867288479264346469f7431 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Tue, 14 Jul 2015 10:26:09 +0100 -Subject: [PATCH 009/199] spidev: Add "spidev" compatible string to silence +Subject: [PATCH 010/129] spidev: Add "spidev" compatible string to silence warning See: https://github.com/raspberrypi/linux/issues/1054 @@ -539,10 +578,10 @@ index cda10719d1d1b21b32866d2b79363faa461ab8e1..4f3779d3aa0960640506725bde918075 }; MODULE_DEVICE_TABLE(of, spidev_dt_ids); -From 7d9834d2030717ae15fd98ff4d5c62b43f6dd7e8 Mon Sep 17 00:00:00 2001 +From 4bea356be10941992f3dcfeac2f7974abb05ed74 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Tue, 3 Jan 2017 18:25:01 +0000 -Subject: [PATCH 010/199] Revert "pinctrl: bcm2835: switch to GPIOLIB_IRQCHIP" +Subject: [PATCH 011/129] Revert "pinctrl: bcm2835: switch to GPIOLIB_IRQCHIP" This reverts commit 85ae9e512f437cd09bf61564bdba29ab88bab3e3. --- @@ -841,10 +880,10 @@ index 230883168e99a1a3fecc7916ef0a7e0de7e8b3f1..ff3789a11b3c36b922b9d08035abb638 if (IS_ERR(pc->pctl_dev)) { gpiochip_remove(&pc->gpio_chip); -From 4f57071b9819ffd2ff957599813355b846019f28 Mon Sep 17 00:00:00 2001 +From 1490a00a1591a44f00f128903052e075456a765c Mon Sep 17 00:00:00 2001 From: notro Date: Thu, 10 Jul 2014 13:59:47 +0200 -Subject: [PATCH 011/199] pinctrl-bcm2835: Set base to 0 give expected gpio +Subject: [PATCH 012/129] pinctrl-bcm2835: Set base to 0 give expected gpio numbering Signed-off-by: Noralf Tronnes @@ -866,10 +905,10 @@ index ff3789a11b3c36b922b9d08035abb638187c2f5a..d2b537572095c86576f78536f737c102 .can_sleep = false, }; -From b8e7337d276dc67817fa2ee63531878bd6e1886d Mon Sep 17 00:00:00 2001 +From e60b8d2799a20fab024ac1cff86087763d0c5cd9 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 26 Feb 2015 09:58:22 +0000 -Subject: [PATCH 012/199] pinctrl-bcm2835: Only request the interrupts listed +Subject: [PATCH 013/129] pinctrl-bcm2835: Only request the interrupts listed in the DTB Although the GPIO controller can generate three interrupts (four counting @@ -896,10 +935,10 @@ index d2b537572095c86576f78536f737c102487f99f4..a9d480df32562defbf8be0faf0a39bfe pc->irq_data[i].irqgroup = i; -From d8bc489c37aa1460350ce28389b2698b0f67860d Mon Sep 17 00:00:00 2001 +From b91abfd233fffb8f22735c8428f5a8af367f9387 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 24 Jun 2015 14:10:44 +0100 -Subject: [PATCH 013/199] spi-bcm2835: Support pin groups other than 7-11 +Subject: [PATCH 014/129] spi-bcm2835: Support pin groups other than 7-11 The spi-bcm2835 driver automatically uses GPIO chip-selects due to some unreliability of the native ones. In doing so it chooses the @@ -980,10 +1019,10 @@ index f35cc10772f6670397ea923ad30158270dd68578..5dfe20ffc2866fa6789825016c585175 /* and set up the "mode" and level */ dev_info(&spi->dev, "setting up native-CS%i as GPIO %i\n", -From d18b5a8d4af342ac91714fec7e41264d6a914783 Mon Sep 17 00:00:00 2001 +From 142bcdabeeaad29d9aeecf26cf16c4de71764c7f Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Fri, 1 Jul 2016 22:09:24 +0100 -Subject: [PATCH 014/199] spi-bcm2835: Disable forced software CS +Subject: [PATCH 015/129] spi-bcm2835: Disable forced software CS Select software CS in bcm2708_common.dtsi, and disable the automatic conversion in the driver to allow hardware CS to be re-enabled with an @@ -1017,10 +1056,10 @@ index 5dfe20ffc2866fa6789825016c585175a29705b6..8493474d286f7a1ac6454a22c61c8c2c return 0; } -From ea9488258ddc1f00a0003c3984f1cee438378ab9 Mon Sep 17 00:00:00 2001 +From b32e05f02e7113f460c6cbfa7e28539fc2dd4966 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Tue, 8 Nov 2016 21:35:38 +0000 -Subject: [PATCH 015/199] spi-bcm2835: Remove unused code +Subject: [PATCH 016/129] spi-bcm2835: Remove unused code --- drivers/spi/spi-bcm2835.c | 61 ----------------------------------------------- @@ -1108,10 +1147,10 @@ index 8493474d286f7a1ac6454a22c61c8c2cef9121bf..33d75ad38a7f77d085321ace9101900a } -From 0db6b7e0494f20e30285b5089dcf5c55e9f4e672 Mon Sep 17 00:00:00 2001 +From 59fa945c6c2a113a1a19d0d80df344b5d53efe91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Wed, 3 Jun 2015 12:26:13 +0200 -Subject: [PATCH 016/199] ARM: bcm2835: Set Serial number and Revision +Subject: [PATCH 017/129] ARM: bcm2835: Set Serial number and Revision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -1164,10 +1203,10 @@ index 0c1edfc98696da0e0bb7f4a18cdfbcdd27a9795d..8f152266ba9b470df2eaaed9ebcf158e static const char * const bcm2835_compat[] = { -From 8180a30d797d5b2f7ac24178b66e4be7a8329e80 Mon Sep 17 00:00:00 2001 +From 851f7772f6ef6d244cddc90cdb8fd50d82193aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Sat, 3 Oct 2015 22:22:55 +0200 -Subject: [PATCH 017/199] dmaengine: bcm2835: Load driver early and support +Subject: [PATCH 018/129] dmaengine: bcm2835: Load driver early and support legacy API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -1270,10 +1309,10 @@ index 6204cc32d09c5096df8aec304c3c37b3bcb6be44..599c218dc8a73172dd4bd4a058fc8f95 MODULE_ALIAS("platform:bcm2835-dma"); MODULE_DESCRIPTION("BCM2835 DMA engine driver"); -From 1aa512d02cd19f4cfb743c94bf52e126a6aab9b2 Mon Sep 17 00:00:00 2001 +From 1baf343ec1f8cecd2bd4b59f38428c08dabea9a5 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Mon, 25 Jan 2016 17:25:12 +0000 -Subject: [PATCH 018/199] firmware: Updated mailbox header +Subject: [PATCH 019/129] firmware: Updated mailbox header --- include/soc/bcm2835/raspberrypi-firmware.h | 9 +++++++++ @@ -1334,10 +1373,10 @@ index cb979ad90401e299344dd5fae38d09c489d8bd58..30fb37fe175df604a738258a2a632bca RPI_FIRMWARE_VCHIQ_INIT = 0x00048010, -From 38d9e18c5e01d03b752bda3a6f1fc0f3ae7bf86c Mon Sep 17 00:00:00 2001 +From 45420f837ce4f053696b2e43d082b9f51082fb94 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 15 Jun 2016 16:48:41 +0100 -Subject: [PATCH 019/199] rtc: Add SPI alias for pcf2123 driver +Subject: [PATCH 020/129] rtc: Add SPI alias for pcf2123 driver Without this alias, Device Tree won't cause the driver to be loaded. @@ -1357,10 +1396,10 @@ index 8895f77726e8da5444afcd602dceff8f25a9b3fd..1833b8853ceb0e6147cceb93a00e558c MODULE_LICENSE("GPL"); +MODULE_ALIAS("spi:rtc-pcf2123"); -From 0bc915650477b0a838729554c2542622f3635de7 Mon Sep 17 00:00:00 2001 +From 6e7df38d91f738603798f9c5c0e24b191265f187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Fri, 7 Oct 2016 16:50:59 +0200 -Subject: [PATCH 020/199] watchdog: bcm2835: Support setting reboot partition +Subject: [PATCH 021/129] watchdog: bcm2835: Support setting reboot partition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -1462,10 +1501,10 @@ index b339e0e67b4c1275fd4992fea4f1e24c0575b783..26b7177573fac2af1cd4ab5488d2686f static int bcm2835_wdt_probe(struct platform_device *pdev) -From 672bf092f0da6498bc85ab600926a3558deef1c9 Mon Sep 17 00:00:00 2001 +From ff7e96d10d16caddbe8019ab989a4f5394f4d8a5 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Tue, 5 Apr 2016 19:40:12 +0100 -Subject: [PATCH 021/199] reboot: Use power off rather than busy spinning when +Subject: [PATCH 022/129] reboot: Use power off rather than busy spinning when halt is requested --- @@ -1488,10 +1527,10 @@ index 3b2aa9a9fe268d45335f781c4aa22cf573753a1b..0180d89a34af45c56243fe0f17fbe209 /* -From b59a4c2617f1ee0d62c81167124ac24c25d241f2 Mon Sep 17 00:00:00 2001 +From 9285772bbe4713f5ae62666f915fadf142945771 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Wed, 9 Nov 2016 13:02:52 +0000 -Subject: [PATCH 022/199] bcm: Make RASPBERRYPI_POWER depend on PM +Subject: [PATCH 023/129] bcm: Make RASPBERRYPI_POWER depend on PM --- drivers/soc/bcm/Kconfig | 1 + @@ -1510,10 +1549,10 @@ index 49f1e2a75d614bc21db152327c7b425ae2504f8d..dccd2374ed00631abd441e3e9d78ee74 help This enables support for the RPi power domains which can be enabled -From 88b8bed65fa73493e980d4f8ec9780f59581882d Mon Sep 17 00:00:00 2001 +From dbe71688c63bb1f60fed3b9de5a92884d9646b5a Mon Sep 17 00:00:00 2001 From: Martin Sperl Date: Fri, 2 Sep 2016 16:45:27 +0100 -Subject: [PATCH 023/199] Register the clocks early during the boot process, so +Subject: [PATCH 024/129] Register the clocks early during the boot process, so that special/critical clocks can get enabled early on in the boot process avoiding the risk of disabling a clock, pll_divider or pll when a claiming driver fails to install propperly - maybe it needs to defer. @@ -1558,10 +1597,10 @@ index 58ce6af8452db9ca8b4d3c380a06e448919f6a8d..11d89d106026f15719ea25047d6f357b MODULE_AUTHOR("Eric Anholt "); MODULE_DESCRIPTION("BCM2835 clock driver"); -From 2cd8ff99a1e23729e35c6464a32be5510b2d2479 Mon Sep 17 00:00:00 2001 +From 5f3e30fa16d92cb9a91ea15481218a4509373809 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Tue, 6 Dec 2016 17:05:39 +0000 -Subject: [PATCH 024/199] bcm2835-rng: Avoid initialising if already enabled +Subject: [PATCH 025/129] bcm2835-rng: Avoid initialising if already enabled Avoids the 0x40000 cycles of warmup again if firmware has already used it --- @@ -1587,10 +1626,10 @@ index 574211a495491d9d6021dcaefe4274a63ed02055..e66c0fca8c6090e32f72796c0877a1cf err = hwrng_register(&bcm2835_rng_ops); if (err) { -From 3212252aa0321a5ec8cf4fd69756984f87d11142 Mon Sep 17 00:00:00 2001 +From 95a3415f7b64beaf568d328bc4b0c04b1276e216 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 24 Aug 2016 16:28:44 +0100 -Subject: [PATCH 025/199] kbuild: Ignore dtco targets when filtering symbols +Subject: [PATCH 026/129] kbuild: Ignore dtco targets when filtering symbols --- scripts/Kbuild.include | 2 +- @@ -1610,10 +1649,10 @@ index 9ffd3dda3889c56a7a72229bed21ff5c49d62856..00da6c9bacbf33334233e22ca5209ade esac | tr ";" "\n" | sed -rn 's/^.*=== __KSYM_(.*) ===.*$$/KSYM_\1/p' -From c5260941f2ede85922a645a4e310911c5d74574a Mon Sep 17 00:00:00 2001 +From 7f5a3c3e22445e1c935f15060d93a6b823446ebf Mon Sep 17 00:00:00 2001 From: Robert Tiemann Date: Mon, 20 Jul 2015 11:01:25 +0200 -Subject: [PATCH 026/199] BCM2835_DT: Fix I2S register map +Subject: [PATCH 027/129] BCM2835_DT: Fix I2S register map --- Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.txt | 4 ++-- @@ -1651,10 +1690,10 @@ index 65783de0aedf3da79adc36fd077b7a89954ddb6b..a89fe4220fdc3f26f75ee66daf187554 dmas = <&dma 2>, <&dma 3>; -From 50ecc18dc33dabcc2ced1b4dee5673822ccc01c1 Mon Sep 17 00:00:00 2001 +From 93f660db6c7099c40cd8c16d83ae7ff0f9b18861 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 13 Feb 2017 17:20:08 +0000 -Subject: [PATCH 027/199] clk-bcm2835: Mark used PLLs and dividers CRITICAL +Subject: [PATCH 028/129] clk-bcm2835: Mark used PLLs and dividers CRITICAL The VPU configures and relies on several PLLs and dividers. Mark all enabled dividers and their PLLs as CRITICAL to prevent the kernel from @@ -1682,10 +1721,10 @@ index 11d89d106026f15719ea25047d6f357b4bfcb2c5..fe8f5d65f2749cb3ddc878df61664826 divider->data = data; -From b4f6f6ceec4023b92d2e8924f9d8bfbdbb58fdce Mon Sep 17 00:00:00 2001 +From f15722cc677ff919810f2c3bc95da69b413abb8e Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 13 Feb 2017 17:20:08 +0000 -Subject: [PATCH 028/199] clk-bcm2835: Add claim-clocks property +Subject: [PATCH 029/129] clk-bcm2835: Add claim-clocks property The claim-clocks property can be used to prevent PLLs and dividers from being marked as critical. It contains a vector of clock IDs, @@ -1787,10 +1826,10 @@ index fe8f5d65f2749cb3ddc878df616648267441e0ee..92b5e0f5145b32d3bfc3592fe381e8be sizeof(cprman_parent_names)); of_clk_parent_fill(dev->of_node, cprman->real_parent_names, -From 859301a74f46e2ec3087634913262db2a470434a Mon Sep 17 00:00:00 2001 +From 50b91b4c4a65d4ff603623a46c8888c87ce1734b Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 6 Mar 2017 09:06:18 +0000 -Subject: [PATCH 029/199] clk-bcm2835: Read max core clock from firmware +Subject: [PATCH 030/129] clk-bcm2835: Read max core clock from firmware The VPU is responsible for managing the core clock, usually under direction from the bcm2835-cpufreq driver but not via the clk-bcm2835 @@ -1905,10 +1944,51 @@ index 92b5e0f5145b32d3bfc3592fe381e8be3cd90c72..336f8c9c44325d0a94e591a8557f7af2 for (i = 0; !of_property_read_u32_index(pdev->dev.of_node, "claim-clocks", -From e28a4010f2ffb4db99e34661a4bcaccb70c4cb0c Mon Sep 17 00:00:00 2001 +From 2fe9423b6ac762dcf113b5f21ba1de91bbec1b4c Mon Sep 17 00:00:00 2001 +From: Eric Anholt +Date: Mon, 9 May 2016 17:28:18 -0700 +Subject: [PATCH 031/129] clk: bcm2835: Mark GPIO clocks enabled at boot as + critical. + +These divide off of PLLD_PER and are used for the ethernet and wifi +PHYs source PLLs. Neither of them is currently represented by a phy +device that would grab the clock for us. + +This keeps other drivers from killing the networking PHYs when they +disable their own clocks and trigger PLLD_PER's refcount going to 0. + +v2: Skip marking as critical if they aren't on at boot. + +Signed-off-by: Eric Anholt +--- + drivers/clk/bcm/clk-bcm2835.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c +index 336f8c9c44325d0a94e591a8557f7af246adc857..caa05e5ad0b7b5cd683e04fb3591a3dfcb40823f 100644 +--- a/drivers/clk/bcm/clk-bcm2835.c ++++ b/drivers/clk/bcm/clk-bcm2835.c +@@ -1484,6 +1484,15 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, + init.flags = data->flags | CLK_IGNORE_UNUSED; + + /* ++ * Some GPIO clocks for ethernet/wifi PLLs are marked as ++ * critical (since some platforms use them), but if the ++ * firmware didn't have them turned on then they clearly ++ * aren't actually critical. ++ */ ++ if ((cprman_read(cprman, data->ctl_reg) & CM_ENABLE) == 0) ++ init.flags &= ~CLK_IS_CRITICAL; ++ ++ /* + * Pass the CLK_SET_RATE_PARENT flag if we are allowed to propagate + * rate changes on at least of the parents. + */ + +From 54e5cd6f19e27a6aa5480cab1cb5f419132de958 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 9 Feb 2017 14:36:44 +0000 -Subject: [PATCH 030/199] sound: Demote deferral errors to INFO level +Subject: [PATCH 032/129] sound: Demote deferral errors to INFO level At present there is no mechanism to specify driver load order, which can lead to deferrals and repeated retries until successful. @@ -1943,10 +2023,10 @@ index 13c875e2392a40ec5651d7c12a28b9ac9f3aab85..23d56057e49b5ff6b6c3c352c150fee8 goto _err_defer; } -From e8cd11388ae567c9267fbf2901a3e4413837e45d Mon Sep 17 00:00:00 2001 +From 8f6a785e3320079f9a2bca412fa103bb12dbb63f Mon Sep 17 00:00:00 2001 From: Claggy3 Date: Sat, 11 Feb 2017 14:00:30 +0000 -Subject: [PATCH 031/199] Update vfpmodule.c +Subject: [PATCH 033/129] Update vfpmodule.c Christopher Alexander Tobias Schulze - May 2, 2015, 11:57 a.m. This patch fixes a problem with VFP state save and restore related @@ -2083,10 +2163,10 @@ index a71a48e71fffa8626fe90106815376c44bbe679b..d6c0a5a0a5ae3510db3ace5e3f5d3410 /* * Save the userland NEON/VFP state. Under UP, -From ff3216e3c1b8c1ac6c7b45c19371b16471afc834 Mon Sep 17 00:00:00 2001 +From f9b54f14e038729bbec2b16ee15975993681d288 Mon Sep 17 00:00:00 2001 From: Matt Flax Date: Wed, 8 Mar 2017 21:13:24 +1100 -Subject: [PATCH 032/199] ASoC: bcm2835_i2s.c: relax the ch2 register setting +Subject: [PATCH 034/129] ASoC: bcm2835_i2s.c: relax the ch2 register setting for 8 channels This patch allows ch2 registers to be set for 8 channels of audio. @@ -2107,10 +2187,10 @@ index 6ba20498202ed36906b52096893a88867a79269f..56df7d8a43d0aac055a91b0d24aca8e1 format |= BCM2835_I2S_CH1(BCM2835_I2S_CHPOS(ch1pos)); format |= BCM2835_I2S_CH2(BCM2835_I2S_CHPOS(ch2pos)); -From 5d1b18b32af4ca040892a16ddbf5d0f71e8214cd Mon Sep 17 00:00:00 2001 +From f2a96f0a5b4f2a91884e0e7fcfeb8099e044821f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Tue, 1 Nov 2016 15:15:41 +0100 -Subject: [PATCH 033/199] i2c: bcm2835: Add debug support +Subject: [PATCH 035/129] i2c: bcm2835: Add debug support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -2299,10 +2379,104 @@ index cd07a69e2e9355540442785f95e90823b05c9d10..47167f403cc8329bd811b47c7011c299 if (i2c_dev->msg_err & BCM2835_I2C_S_ERR) return -EREMOTEIO; -From 3d037db93f7c96c91d15f497be5dd5c57862553b Mon Sep 17 00:00:00 2001 +From e30fc8d777e15b35526ad0427c2177b099dee7b1 Mon Sep 17 00:00:00 2001 +From: Eric Anholt +Date: Thu, 18 Dec 2014 16:07:15 -0800 +Subject: [PATCH 036/129] mm: Remove the PFN busy warning + +See commit dae803e165a11bc88ca8dbc07a11077caf97bbcb -- the warning is +expected sometimes when using CMA. However, that commit still spams +my kernel log with these warnings. + +Signed-off-by: Eric Anholt +--- + mm/page_alloc.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/mm/page_alloc.c b/mm/page_alloc.c +index 1423da8dd16f5bdc83e20ddf6665b2022a9a6492..6ce930c02160d55dc4eee1e7197a5efa6ba7d44a 100644 +--- a/mm/page_alloc.c ++++ b/mm/page_alloc.c +@@ -7692,8 +7692,6 @@ int alloc_contig_range(unsigned long start, unsigned long end, + + /* Make sure the range is really isolated. */ + if (test_pages_isolated(outer_start, end, false)) { +- pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n", +- __func__, outer_start, end); + ret = -EBUSY; + goto done; + } + +From bf033ea532a9005ade064ce2afc23be81ee7b545 Mon Sep 17 00:00:00 2001 +From: Phil Elwell +Date: Thu, 23 Mar 2017 10:06:56 +0000 +Subject: [PATCH 037/129] ASoC: Add prompt for ICS43432 codec + +Without a prompt string, a config setting can't be included in a +defconfig. Give CONFIG_SND_SOC_ICS43432 a prompt so that Pi soundcards +can use the driver. + +Signed-off-by: Phil Elwell +--- + sound/soc/codecs/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig +index 6c78b0b49b8145c24740d93c4174c059d91ddae9..d6450d5fc144737f967b8e00678baa9b8f92295f 100644 +--- a/sound/soc/codecs/Kconfig ++++ b/sound/soc/codecs/Kconfig +@@ -571,7 +571,7 @@ config SND_SOC_HDAC_HDMI + select HDMI + + config SND_SOC_ICS43432 +- tristate ++ tristate "InvenSense ICS43432 I2S microphone codec" + + config SND_SOC_INNO_RK3036 + tristate "Inno codec driver for RK3036 SoC" + +From 7716560b318c6a16a4ceb38da22d6c595e63fbf4 Mon Sep 17 00:00:00 2001 +From: Phil Elwell +Date: Thu, 18 May 2017 15:36:46 +0100 +Subject: [PATCH 038/129] staging: bcm2835-audio: Fix memory corruption + +I'm all for fixing memory leaks, but freeing a block while it is still +being used is a recipe for hard-to-debug kernel exeptions. + +1) There is already a vchi method for freeing the instance, so use it. +2) Only call it on error, and then only before initted is false. + +Signed-off-by: Phil Elwell +Fixes: 0adbfd4694c2 ("staging: bcm2835-audio: fix memory leak in bcm2835_audio_open_connection()") +--- + drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +index 5f3d8f2339e34834d11edfa8de1d5819e3e32b4f..89f96f3c02805f4114ec9b488e18d00e1f348239 100644 +--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c ++++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +@@ -409,6 +409,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream + LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n", + __func__, ret); + ++ vchi_disconnect(vchi_instance); + ret = -EIO; + goto err_free_mem; + } +@@ -431,7 +432,6 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream + LOG_DBG(" success !\n"); + ret = 0; + err_free_mem: +- kfree(vchi_instance); + + return ret; + } + +From 168be2ce0a4e8cb82477498fd0c2d2b52dea3d6a Mon Sep 17 00:00:00 2001 From: popcornmix Date: Sun, 12 May 2013 12:24:19 +0100 -Subject: [PATCH 034/199] Main bcm2708/bcm2709 linux port +Subject: [PATCH 039/129] Main bcm2708/bcm2709 linux port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -2490,10 +2664,10 @@ index cfb4b4496dd9f61362dea012176c146120fada07..d9c6c217c4d6a2408abe2665bf7f2700 MODULE_AUTHOR("Lubomir Rintel "); MODULE_DESCRIPTION("BCM2835 mailbox IPC driver"); -From 00be68ede1ad301334e709edcecba80422fca888 Mon Sep 17 00:00:00 2001 +From 4a742c0460e2d8993349b9142603d7b16593c446 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Wed, 1 May 2013 19:46:17 +0100 -Subject: [PATCH 035/199] Add dwc_otg driver +Subject: [PATCH 040/129] Add dwc_otg driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -3069,6 +3243,47 @@ in hcd->free_hc_list becoming corrupted. dwcotg: Allow to build without FIQ on ARM64 Signed-off-by: popcornmix + +dwc_otg: make periodic scheduling behave properly for FS buses + +If the root port is in full-speed mode, transfer times at 12mbit/s +would be calculated but matched against high-speed quotas. + +Reinitialise hcd->frame_usecs[i] on each port enable event so that +full-speed bandwidth can be tracked sensibly. + +Also, don't bother using the FIQ for transfers when in full-speed +mode - at the slower bus speed, interrupt frequency is reduced by +an order of magnitude. + +Related issue: https://github.com/raspberrypi/linux/issues/2020 + +dwc_otg: fiq_fsm: Make isochronous compatibility checks work properly + +Get rid of the spammy printk and local pointer mangling. +Also, there is a nominal benefit for using fiq_fsm for isochronous +transfers in FS mode (~1.1k IRQs per second vs 2.1k IRQs per second) +so remove the root port speed check. + +dwc_otg: add module parameter int_ep_interval_min + +Add a module parameter (defaulting to ignored) that clamps the polling rate +of high-speed Interrupt endpoints to a minimum microframe interval. + +The parameter is modifiable at runtime as it is used when activating new +endpoints (such as on device connect). + +dwc_otg: fiq_fsm: Add non-periodic TT exclusivity constraints + +Certain hub types do not discriminate between pipe direction (IN or OUT) +when considering non-periodic transfers. Therefore these hubs get confused +if multiple transfers are issued in different directions with the same +device address and endpoint number. + +Constrain queuing non-periodic split transactions so they are performed +serially in such cases. + +Related: https://github.com/raspberrypi/linux/issues/2024 --- arch/arm/include/asm/irqflags.h | 16 +- arch/arm/kernel/fiqasm.S | 4 + @@ -3117,18 +3332,18 @@ Signed-off-by: popcornmix drivers/usb/host/dwc_otg/dwc_otg_cil_intr.c | 1596 +++++ drivers/usb/host/dwc_otg/dwc_otg_core_if.h | 705 ++ drivers/usb/host/dwc_otg/dwc_otg_dbg.h | 117 + - drivers/usb/host/dwc_otg/dwc_otg_driver.c | 1757 +++++ + drivers/usb/host/dwc_otg/dwc_otg_driver.c | 1761 +++++ drivers/usb/host/dwc_otg/dwc_otg_driver.h | 86 + - drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c | 1358 ++++ - drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h | 370 + + drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c | 1390 ++++ + drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h | 372 + drivers/usb/host/dwc_otg/dwc_otg_fiq_stub.S | 80 + - drivers/usb/host/dwc_otg/dwc_otg_hcd.c | 4242 ++++++++++++ - drivers/usb/host/dwc_otg/dwc_otg_hcd.h | 867 +++ + drivers/usb/host/dwc_otg/dwc_otg_hcd.c | 4284 ++++++++++++ + drivers/usb/host/dwc_otg/dwc_otg_hcd.h | 870 +++ drivers/usb/host/dwc_otg/dwc_otg_hcd_ddma.c | 1134 ++++ drivers/usb/host/dwc_otg/dwc_otg_hcd_if.h | 417 ++ - drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c | 2749 ++++++++ + drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c | 2753 ++++++++ drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c | 1007 +++ - drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c | 967 +++ + drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c | 971 +++ drivers/usb/host/dwc_otg/dwc_otg_os_dep.h | 188 + drivers/usb/host/dwc_otg/dwc_otg_pcd.c | 2725 ++++++++ drivers/usb/host/dwc_otg/dwc_otg_pcd.h | 273 + @@ -3140,7 +3355,7 @@ Signed-off-by: popcornmix drivers/usb/host/dwc_otg/test/dwc_otg_test.pm | 337 + drivers/usb/host/dwc_otg/test/test_mod_param.pl | 133 + drivers/usb/host/dwc_otg/test/test_sysfs.pl | 193 + - 70 files changed, 59917 insertions(+), 16 deletions(-) + 70 files changed, 60008 insertions(+), 16 deletions(-) create mode 100644 drivers/usb/gadget/file_storage.c create mode 100644 drivers/usb/host/dwc_common_port/Makefile create mode 100644 drivers/usb/host/dwc_common_port/Makefile.fbsd @@ -35260,10 +35475,10 @@ index 0000000000000000000000000000000000000000..ccc24e010e449cbda488050d901e9a39 +#endif diff --git a/drivers/usb/host/dwc_otg/dwc_otg_driver.c b/drivers/usb/host/dwc_otg/dwc_otg_driver.c new file mode 100644 -index 0000000000000000000000000000000000000000..cb060a7179a3eec791506ed2779b553cad9841b0 +index 0000000000000000000000000000000000000000..95943e07528276b26b51ea2d57a1f433f280aaef --- /dev/null +++ b/drivers/usb/host/dwc_otg/dwc_otg_driver.c -@@ -0,0 +1,1757 @@ +@@ -0,0 +1,1761 @@ +/* ========================================================================== + * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_driver.c $ + * $Revision: #92 $ @@ -35515,6 +35730,7 @@ index 0000000000000000000000000000000000000000..cb060a7179a3eec791506ed2779b553c + +unsigned short fiq_fsm_mask = 0x0F; + ++unsigned short int_ep_interval_min = 0; +/** + * This function shows the Driver Version. + */ @@ -36664,7 +36880,10 @@ index 0000000000000000000000000000000000000000..cb060a7179a3eec791506ed2779b553c + "Bit 1 : Periodic split transactions\n" + "Bit 2 : High-speed multi-transfer isochronous\n" + "All other bits should be set 0."); -+ ++module_param(int_ep_interval_min, ushort, 0644); ++MODULE_PARM_DESC(int_ep_interval_min, "Clamp high-speed Interrupt endpoints to a minimum polling interval.\n" ++ "0..1 = Use endpoint default\n" ++ "2..n = Minimum interval n microframes. Use powers of 2.\n"); + +/** @page "Module Parameters" + * @@ -37115,10 +37334,10 @@ index 0000000000000000000000000000000000000000..6a8be63a0ab20f4e1c56251b85648aa2 +#endif diff --git a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c new file mode 100644 -index 0000000000000000000000000000000000000000..2035e0762dc6d60673c8fbc47a90b72254f50b69 +index 0000000000000000000000000000000000000000..b7731e7edb4602f93f028d786194822161bbf0f8 --- /dev/null +++ b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c -@@ -0,0 +1,1358 @@ +@@ -0,0 +1,1390 @@ +/* + * dwc_otg_fiq_fsm.c - The finite state machine FIQ + * @@ -37295,6 +37514,32 @@ index 0000000000000000000000000000000000000000..2035e0762dc6d60673c8fbc47a90b722 + mb(); +} + ++/** ++ * fiq_fsm_restart_np_pending() - Restart a single non-periodic contended transfer ++ * @st: Pointer to the channel's state ++ * @num_channels: Total number of host channels ++ * @orig_channel: Channel index of completed transfer ++ * ++ * In the case where an IN and OUT transfer are simultaneously scheduled to the ++ * same device/EP, inadequate hub implementations will misbehave. Once the first ++ * transfer is complete, a pending non-periodic split can then be issued. ++ */ ++static void notrace fiq_fsm_restart_np_pending(struct fiq_state *st, int num_channels, int orig_channel) ++{ ++ int i; ++ int dev_addr = st->channel[orig_channel].hcchar_copy.b.devaddr; ++ int ep_num = st->channel[orig_channel].hcchar_copy.b.epnum; ++ for (i = 0; i < num_channels; i++) { ++ if (st->channel[i].fsm == FIQ_NP_SSPLIT_PENDING && ++ st->channel[i].hcchar_copy.b.devaddr == dev_addr && ++ st->channel[i].hcchar_copy.b.epnum == ep_num) { ++ st->channel[i].fsm = FIQ_NP_SSPLIT_STARTED; ++ fiq_fsm_restart_channel(st, i, 0); ++ break; ++ } ++ } ++} ++ +static inline int notrace fiq_get_xfer_len(struct fiq_state *st, int n) +{ + /* The xfersize register is a bit wonky. For IN transfers, it decrements by the packet size. */ @@ -37974,6 +38219,9 @@ index 0000000000000000000000000000000000000000..2035e0762dc6d60673c8fbc47a90b722 + st->fsm = FIQ_NP_SPLIT_HS_ABORTED; + } + } ++ if (st->fsm != FIQ_NP_IN_CSPLIT_RETRY) { ++ fiq_fsm_restart_np_pending(state, num_channels, n); ++ } + break; + + case FIQ_NP_OUT_CSPLIT_RETRY: @@ -38023,6 +38271,9 @@ index 0000000000000000000000000000000000000000..2035e0762dc6d60673c8fbc47a90b722 + st->fsm = FIQ_NP_SPLIT_HS_ABORTED; + } + } ++ if (st->fsm != FIQ_NP_OUT_CSPLIT_RETRY) { ++ fiq_fsm_restart_np_pending(state, num_channels, n); ++ } + break; + + /* Periodic split states (except isoc out) */ @@ -38479,10 +38730,10 @@ index 0000000000000000000000000000000000000000..2035e0762dc6d60673c8fbc47a90b722 +} diff --git a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h new file mode 100644 -index 0000000000000000000000000000000000000000..f9fddfbcffb37f32c808fd78f222b676378398b1 +index 0000000000000000000000000000000000000000..8340041ce65665c094e2ad49fd5e8eb1751506f3 --- /dev/null +++ b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h -@@ -0,0 +1,370 @@ +@@ -0,0 +1,372 @@ +/* + * dwc_otg_fiq_fsm.h - Finite state machine FIQ header definitions + * @@ -38655,6 +38906,8 @@ index 0000000000000000000000000000000000000000..f9fddfbcffb37f32c808fd78f222b676 + /* Nonperiodic state groups */ + FIQ_NP_SSPLIT_STARTED = 1, + FIQ_NP_SSPLIT_RETRY = 2, ++ /* TT contention - working around hub bugs */ ++ FIQ_NP_SSPLIT_PENDING = 33, + FIQ_NP_OUT_CSPLIT_RETRY = 3, + FIQ_NP_IN_CSPLIT_RETRY = 4, + FIQ_NP_SPLIT_DONE = 5, @@ -38941,10 +39194,10 @@ index 0000000000000000000000000000000000000000..ffa8d21bc61e893fee86ba04955587e7 +END(_dwc_otg_fiq_stub) diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c new file mode 100644 -index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df0de772a8 +index 0000000000000000000000000000000000000000..60464acab588a1e189f39b268ffc25766c13dc85 --- /dev/null +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -@@ -0,0 +1,4242 @@ +@@ -0,0 +1,4284 @@ + +/* ========================================================================== + * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_hcd.c $ @@ -39873,8 +40126,6 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + DWC_FREE(dwc_otg_hcd); +} + -+int init_hcd_usecs(dwc_otg_hcd_t *_hcd); -+ +int dwc_otg_hcd_init(dwc_otg_hcd_t * hcd, dwc_otg_core_if_t * core_if) +{ + struct device *dev = dwc_otg_hcd_to_dev(hcd); @@ -40372,6 +40623,7 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + +/** + * fiq_fsm_transaction_suitable() - Test a QH for compatibility with the FIQ ++ * @hcd: Pointer to the dwc_otg_hcd struct + * @qh: pointer to the endpoint's queue head + * + * Transaction start/end control flow is grafted onto the existing dwc_otg @@ -40381,7 +40633,7 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + * Returns: 0 for unsuitable, 1 implies the FIQ can be enabled for this transaction. + */ + -+int fiq_fsm_transaction_suitable(dwc_otg_qh_t *qh) ++int fiq_fsm_transaction_suitable(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) +{ + if (qh->do_split) { + switch (qh->ep_type) { @@ -40400,28 +40652,22 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + } + } else if (qh->ep_type == UE_ISOCHRONOUS) { + if (fiq_fsm_mask & (1 << 2)) { -+ /* HS ISOCH support. We test for compatibility: ++ /* ISOCH support. We test for compatibility: + * - DWORD aligned buffers + * - Must be at least 2 transfers (otherwise pointless to use the FIQ) + * If yes, then the fsm enqueue function will handle the state machine setup. + */ + dwc_otg_qtd_t *qtd = DWC_CIRCLEQ_FIRST(&qh->qtd_list); + dwc_otg_hcd_urb_t *urb = qtd->urb; -+ struct dwc_otg_hcd_iso_packet_desc (*iso_descs)[0] = &urb->iso_descs; -+ int nr_iso_frames = urb->packet_count; ++ dwc_dma_t ptr; + int i; -+ uint32_t ptr; + -+ if (nr_iso_frames < 2) ++ if (urb->packet_count < 2) + return 0; -+ for (i = 0; i < nr_iso_frames; i++) { -+ ptr = urb->dma + iso_descs[i]->offset; -+ if (ptr & 0x3) { -+ printk_ratelimited("%s: Non-Dword aligned isochronous frame offset." -+ " Cannot queue FIQ-accelerated transfer to device %d endpoint %d\n", -+ __FUNCTION__, qh->channel->dev_addr, qh->channel->ep_num); ++ for (i = 0; i < urb->packet_count; i++) { ++ ptr = urb->dma + urb->iso_descs[i].offset; ++ if (ptr & 0x3) + return 0; -+ } + } + return 1; + } @@ -40522,6 +40768,45 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + } +} + ++/** ++ * fiq_fsm_np_tt_contended() - Avoid performing contended non-periodic transfers ++ * @hcd: Pointer to the dwc_otg_hcd struct ++ * @qh: Pointer to the endpoint's queue head ++ * ++ * Certain hub chips don't differentiate between IN and OUT non-periodic pipes ++ * with the same endpoint number. If transfers get completed out of order ++ * (disregarding the direction token) then the hub can lock up ++ * or return erroneous responses. ++ * ++ * Returns 1 if initiating the transfer would cause contention, 0 otherwise. ++ */ ++int fiq_fsm_np_tt_contended(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) ++{ ++ int i; ++ struct fiq_channel_state *st; ++ int dev_addr = qh->channel->dev_addr; ++ int ep_num = qh->channel->ep_num; ++ for (i = 0; i < hcd->core_if->core_params->host_channels; i++) { ++ if (i == qh->channel->hc_num) ++ continue; ++ st = &hcd->fiq_state->channel[i]; ++ switch (st->fsm) { ++ case FIQ_NP_SSPLIT_STARTED: ++ case FIQ_NP_SSPLIT_RETRY: ++ case FIQ_NP_SSPLIT_PENDING: ++ case FIQ_NP_OUT_CSPLIT_RETRY: ++ case FIQ_NP_IN_CSPLIT_RETRY: ++ if (st->hcchar_copy.b.devaddr == dev_addr && ++ st->hcchar_copy.b.epnum == ep_num) ++ return 1; ++ break; ++ default: ++ break; ++ } ++ } ++ return 0; ++} ++ +/* + * Pushing a periodic request into the queue near the EOF1 point + * in a microframe causes erroneous behaviour (frmovrun) interrupt. @@ -40844,7 +41129,12 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + switch (hc->ep_type) { + case UE_CONTROL: + case UE_BULK: -+ st->fsm = FIQ_NP_SSPLIT_STARTED; ++ if (fiq_fsm_np_tt_contended(hcd, qh)) { ++ st->fsm = FIQ_NP_SSPLIT_PENDING; ++ start_immediate = 0; ++ } else { ++ st->fsm = FIQ_NP_SSPLIT_STARTED; ++ } + break; + case UE_ISOCHRONOUS: + if (hc->ep_is_in) { @@ -40868,7 +41158,12 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + break; + case UE_INTERRUPT: + if (fiq_fsm_mask & 0x8) { -+ st->fsm = FIQ_NP_SSPLIT_STARTED; ++ if (fiq_fsm_np_tt_contended(hcd, qh)) { ++ st->fsm = FIQ_NP_SSPLIT_PENDING; ++ start_immediate = 0; ++ } else { ++ st->fsm = FIQ_NP_SSPLIT_STARTED; ++ } + } else if (start_immediate) { + st->fsm = FIQ_PER_SSPLIT_STARTED; + } else { @@ -41161,7 +41456,7 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + continue; + } + -+ if (fiq_fsm_enable && fiq_fsm_transaction_suitable(qh)) { ++ if (fiq_fsm_enable && fiq_fsm_transaction_suitable(hcd, qh)) { + if (qh->do_split) + fiq_fsm_queue_split_transaction(hcd, qh); + else @@ -41298,7 +41593,7 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df + qh = DWC_LIST_ENTRY(hcd->non_periodic_qh_ptr, dwc_otg_qh_t, + qh_list_entry); + -+ if(fiq_fsm_enable && fiq_fsm_transaction_suitable(qh)) { ++ if(fiq_fsm_enable && fiq_fsm_transaction_suitable(hcd, qh)) { + fiq_fsm_queue_split_transaction(hcd, qh); + } else { + status = queue_transaction(hcd, qh->channel, @@ -43189,10 +43484,10 @@ index 0000000000000000000000000000000000000000..5e4d4ffe7966486d40a5b5e2423ac4df +#endif /* DWC_DEVICE_ONLY */ diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.h b/drivers/usb/host/dwc_otg/dwc_otg_hcd.h new file mode 100644 -index 0000000000000000000000000000000000000000..7f7e9eaffd6a3c3d898855562fbec11289f77f53 +index 0000000000000000000000000000000000000000..5ed8dccf03959a610849aa6c8946ca745dbae207 --- /dev/null +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.h -@@ -0,0 +1,867 @@ +@@ -0,0 +1,870 @@ +/* ========================================================================== + * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_hcd.h $ + * $Revision: #58 $ @@ -43605,7 +43900,8 @@ index 0000000000000000000000000000000000000000..7f7e9eaffd6a3c3d898855562fbec112 + unsigned port_suspend_change:1; + unsigned port_over_current_change:1; + unsigned port_l1_change:1; -+ unsigned reserved:26; ++ unsigned port_speed:2; ++ unsigned reserved:24; + } b; + } flags; + @@ -43824,7 +44120,7 @@ index 0000000000000000000000000000000000000000..7f7e9eaffd6a3c3d898855562fbec112 +void dwc_otg_hcd_release_port(dwc_otg_hcd_t * dwc_otg_hcd, dwc_otg_qh_t *qh); + +extern int fiq_fsm_queue_transaction(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh); -+extern int fiq_fsm_transaction_suitable(dwc_otg_qh_t *qh); ++extern int fiq_fsm_transaction_suitable(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh); +extern void dwc_otg_cleanup_fiq_channel(dwc_otg_hcd_t *hcd, uint32_t num); + +/** @} */ @@ -44018,6 +44314,8 @@ index 0000000000000000000000000000000000000000..7f7e9eaffd6a3c3d898855562fbec112 + return frame & 0x7; +} + ++extern void init_hcd_usecs(dwc_otg_hcd_t *_hcd); ++ +void dwc_otg_hcd_save_data_toggle(dwc_hc_t * hc, + dwc_otg_hc_regs_t * hc_regs, + dwc_otg_qtd_t * qtd); @@ -45625,10 +45923,10 @@ index 0000000000000000000000000000000000000000..fb57db09378f4ab95d57cb58aa570a91 +#endif /* DWC_DEVICE_ONLY */ diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c new file mode 100644 -index 0000000000000000000000000000000000000000..fc52495e4749f45dcf270c1c22960f163b6dc86d +index 0000000000000000000000000000000000000000..ed855eb9c3b64d54e93c5aa7e06212e779400dfd --- /dev/null +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c -@@ -0,0 +1,2749 @@ +@@ -0,0 +1,2753 @@ +/* ========================================================================== + * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_hcd_intr.c $ + * $Revision: #89 $ @@ -46145,6 +46443,10 @@ index 0000000000000000000000000000000000000000..fc52495e4749f45dcf270c1c22960f16 + dwc_otg_host_if_t *host_if = + dwc_otg_hcd->core_if->host_if; + ++ dwc_otg_hcd->flags.b.port_speed = hprt0.b.prtspd; ++ if (microframe_schedule) ++ init_hcd_usecs(dwc_otg_hcd); ++ + /* Every time when port enables calculate + * HFIR.FrInterval + */ @@ -49393,10 +49695,10 @@ index 0000000000000000000000000000000000000000..96ec6338bbcb8ebe69a233d21a4b9d24 +#endif /* DWC_DEVICE_ONLY */ diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c new file mode 100644 -index 0000000000000000000000000000000000000000..85a6d431ca54b47dc10573aa72d1ad69d06f2e36 +index 0000000000000000000000000000000000000000..fe8e8f841f03660c2ad49ab8e66193bec62558d3 --- /dev/null +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c -@@ -0,0 +1,967 @@ +@@ -0,0 +1,971 @@ +/* ========================================================================== + * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_hcd_queue.c $ + * $Revision: #44 $ @@ -49442,6 +49744,7 @@ index 0000000000000000000000000000000000000000..85a6d431ca54b47dc10573aa72d1ad69 +#include "dwc_otg_regs.h" + +extern bool microframe_schedule; ++extern unsigned short int_ep_interval_min; + +/** + * Free each QTD in the QH's QTD-list then free the QH. QH should already be @@ -49617,21 +49920,19 @@ index 0000000000000000000000000000000000000000..85a6d431ca54b47dc10573aa72d1ad69 + SCHEDULE_SLOP); + qh->interval = urb->interval; + -+#if 0 -+ /* Increase interrupt polling rate for debugging. */ -+ if (qh->ep_type == UE_INTERRUPT) { -+ qh->interval = 8; -+ } -+#endif + hprt.d32 = DWC_READ_REG32(hcd->core_if->host_if->hprt0); -+ if ((hprt.b.prtspd == DWC_HPRT0_PRTSPD_HIGH_SPEED) && -+ ((dev_speed == USB_SPEED_LOW) || -+ (dev_speed == USB_SPEED_FULL))) { -+ qh->interval *= 8; -+ qh->sched_frame |= 0x7; -+ qh->start_split_frame = qh->sched_frame; ++ if (hprt.b.prtspd == DWC_HPRT0_PRTSPD_HIGH_SPEED) { ++ if (dev_speed == USB_SPEED_LOW || ++ dev_speed == USB_SPEED_FULL) { ++ qh->interval *= 8; ++ qh->sched_frame |= 0x7; ++ qh->start_split_frame = qh->sched_frame; ++ } else if (int_ep_interval_min >= 2 && ++ qh->interval < int_ep_interval_min && ++ qh->ep_type == UE_INTERRUPT) { ++ qh->interval = int_ep_interval_min; ++ } + } -+ + } + + DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD QH Initialized\n"); @@ -49807,13 +50108,17 @@ index 0000000000000000000000000000000000000000..85a6d431ca54b47dc10573aa72d1ad69 +/* + * called from dwc_otg_hcd.c:dwc_otg_hcd_init + */ -+int init_hcd_usecs(dwc_otg_hcd_t *_hcd) ++void init_hcd_usecs(dwc_otg_hcd_t *_hcd) +{ + int i; -+ for (i=0; i<8; i++) { -+ _hcd->frame_usecs[i] = max_uframe_usecs[i]; ++ if (_hcd->flags.b.port_speed == DWC_HPRT0_PRTSPD_FULL_SPEED) { ++ _hcd->frame_usecs[0] = 900; ++ for (i = 1; i < 8; i++) ++ _hcd->frame_usecs[i] = 0; ++ } else { ++ for (i = 0; i < 8; i++) ++ _hcd->frame_usecs[i] = max_uframe_usecs[i]; + } -+ return 0; +} + +static int find_single_uframe(dwc_otg_hcd_t * _hcd, dwc_otg_qh_t * _qh) @@ -49940,8 +50245,9 @@ index 0000000000000000000000000000000000000000..85a6d431ca54b47dc10573aa72d1ad69 + int ret; + ret = -1; + -+ if (_qh->speed == USB_SPEED_HIGH) { -+ /* if this is a hs transaction we need a full frame */ ++ if (_qh->speed == USB_SPEED_HIGH || ++ _hcd->flags.b.port_speed == DWC_HPRT0_PRTSPD_FULL_SPEED) { ++ /* if this is a hs transaction we need a full frame - or account for FS usecs */ + ret = find_single_uframe(_hcd, _qh); + } else { + /* if this is a fs transaction we may need a sequence of frames */ @@ -50026,7 +50332,7 @@ index 0000000000000000000000000000000000000000..85a6d431ca54b47dc10573aa72d1ad69 + if (status) { + DWC_INFO("%s: Insufficient periodic bandwidth for " + "periodic transfer.\n", __func__); -+ return status; ++ return -DWC_E_NO_SPACE; + } + status = check_max_xfer_size(hcd, qh); + if (status) { @@ -63635,10 +63941,10 @@ index 0000000000000000000000000000000000000000..cdc9963176e5a4a0d5250613b61e26c5 +test_main(); +0; -From 844987ea9f84c46bc183ff9aea1581065d6a07fa Mon Sep 17 00:00:00 2001 +From 20e2c528fbc615b591f94a474454671f53cf3d98 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Wed, 17 Jun 2015 17:06:34 +0100 -Subject: [PATCH 036/199] bcm2708 framebuffer driver +Subject: [PATCH 041/129] bcm2708 framebuffer driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -67097,10 +67403,10 @@ index 3c14e43b82fefe1d32f591d1b2f61d2cd28d0fa8..7626beb6a5bb8df601ddf0f6e6909d1f +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 -From 52f1e764e986ebd07816f26362a5f7d4b020d082 Mon Sep 17 00:00:00 2001 +From c552685dec9406ed78b0ff592da21eda44757cbc Mon Sep 17 00:00:00 2001 From: Florian Meier Date: Fri, 22 Nov 2013 14:22:53 +0100 -Subject: [PATCH 037/199] dmaengine: Add support for BCM2708 +Subject: [PATCH 042/129] dmaengine: Add support for BCM2708 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -67731,10 +68037,10 @@ index 0000000000000000000000000000000000000000..c5bfff2765be4606077e6c8af73040ec + +#endif /* _PLAT_BCM2708_DMA_H */ -From dec8b5244ace6cbebf14759ba726344bdd451e22 Mon Sep 17 00:00:00 2001 +From 2cfc86aae7690a80ab6d6ece491ceaff33e70ca3 Mon Sep 17 00:00:00 2001 From: gellert Date: Fri, 15 Aug 2014 16:35:06 +0100 -Subject: [PATCH 038/199] MMC: added alternative MMC driver +Subject: [PATCH 043/129] MMC: added alternative MMC driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -67817,21 +68123,156 @@ See: https://github.com/raspberrypi/linux/issues/1327 Signed-off-by: Phil Elwell --- + drivers/mmc/core/block.c | 28 +- + drivers/mmc/core/core.c | 3 +- + drivers/mmc/core/host.c | 17 +- + drivers/mmc/core/quirks.h | 8 + drivers/mmc/host/Kconfig | 29 + drivers/mmc/host/Makefile | 1 + - drivers/mmc/host/bcm2835-mmc.c | 1574 ++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 1604 insertions(+) + drivers/mmc/host/bcm2835-mmc.c | 1584 ++++++++++++++++++++++++++++++++++++++++ + include/linux/mmc/card.h | 2 + + 8 files changed, 1667 insertions(+), 5 deletions(-) create mode 100644 drivers/mmc/host/bcm2835-mmc.c +diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c +index 8bd7aba811e969a3b7cfdc6cf12e685f25e8c37e..cd1eb5cf73358a0104fbf4b6ed8e72dd491d658d 100644 +--- a/drivers/mmc/core/block.c ++++ b/drivers/mmc/core/block.c +@@ -125,6 +125,13 @@ static DEFINE_MUTEX(open_lock); + module_param(perdev_minors, int, 0444); + MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device"); + ++/* ++ * Allow quirks to be overridden for the current card ++ */ ++static char *card_quirks; ++module_param(card_quirks, charp, 0644); ++MODULE_PARM_DESC(card_quirks, "Force the use of the indicated quirks (a bitfield)"); ++ + static inline int mmc_blk_part_switch(struct mmc_card *card, + struct mmc_blk_data *md); + +@@ -2287,6 +2294,7 @@ static int mmc_blk_probe(struct mmc_card *card) + { + struct mmc_blk_data *md, *part_md; + char cap_str[10]; ++ char quirk_str[24]; + + /* + * Check that the card supports the command class(es) we need. +@@ -2294,7 +2302,16 @@ static int mmc_blk_probe(struct mmc_card *card) + if (!(card->csd.cmdclass & CCC_BLOCK_READ)) + return -ENODEV; + +- mmc_fixup_device(card, mmc_blk_fixups); ++ if (card_quirks) { ++ unsigned long quirks; ++ if (kstrtoul(card_quirks, 0, &quirks) == 0) ++ card->quirks = (unsigned int)quirks; ++ else ++ pr_err("mmc_block: Invalid card_quirks parameter '%s'\n", ++ card_quirks); ++ } ++ else ++ mmc_fixup_device(card, mmc_blk_fixups); + + md = mmc_blk_alloc(card); + if (IS_ERR(md)) +@@ -2302,9 +2319,14 @@ static int mmc_blk_probe(struct mmc_card *card) + + string_get_size((u64)get_capacity(md->disk), 512, STRING_UNITS_2, + cap_str, sizeof(cap_str)); +- pr_info("%s: %s %s %s %s\n", ++ if (card->quirks) ++ snprintf(quirk_str, sizeof(quirk_str), ++ " (quirks 0x%08x)", card->quirks); ++ else ++ quirk_str[0] = '\0'; ++ pr_info("%s: %s %s %s%s%s\n", + md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), +- cap_str, md->read_only ? "(ro)" : ""); ++ cap_str, md->read_only ? " (ro)" : "", quirk_str); + + if (mmc_blk_alloc_parts(card, md)) + goto out; +diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c +index 26431267a3e2d790d4eae99e65881ca60bd2047d..0ec589ace762a27f3c5ea39226fef3a67442675f 100644 +--- a/drivers/mmc/core/core.c ++++ b/drivers/mmc/core/core.c +@@ -2211,7 +2211,8 @@ EXPORT_SYMBOL(mmc_erase); + int mmc_can_erase(struct mmc_card *card) + { + if ((card->host->caps & MMC_CAP_ERASE) && +- (card->csd.cmdclass & CCC_ERASE) && card->erase_size) ++ (card->csd.cmdclass & CCC_ERASE) && card->erase_size && ++ !(card->quirks & MMC_QUIRK_ERASE_BROKEN)) + return 1; + return 0; + } +diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c +index 1503412f826cd0e0e9ad37a0554b31596a49eb77..2f5b3cf86293b96b104eac7c6d48a5839d7e974b 100644 +--- a/drivers/mmc/core/host.c ++++ b/drivers/mmc/core/host.c +@@ -344,15 +344,30 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) + { + int err; + struct mmc_host *host; ++ int id; + + host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); + if (!host) + return NULL; + ++ /* If OF aliases exist, start dynamic assignment after highest */ ++ id = of_alias_get_highest_id("mmc"); ++ id = (id < 0) ? 0 : id + 1; ++ ++ /* If this devices has OF node, maybe it has an alias */ ++ if (dev->of_node) { ++ int of_id = of_alias_get_id(dev->of_node, "mmc"); ++ ++ if (of_id < 0) ++ dev_warn(dev, "/aliases ID not available\n"); ++ else ++ id = of_id; ++ } ++ + /* scanning will be enabled when we're ready */ + host->rescan_disable = 1; + +- err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL); ++ err = ida_simple_get(&mmc_host_ida, id, 0, GFP_KERNEL); + if (err < 0) { + kfree(host); + return NULL; +diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h +index fb725934fa21cee1b98fd7bc08227bf6d0317549..c9d5d644688c1509d7febcff0322fbaba0a842d6 100644 +--- a/drivers/mmc/core/quirks.h ++++ b/drivers/mmc/core/quirks.h +@@ -90,6 +90,14 @@ static const struct mmc_fixup mmc_blk_fixups[] = { + MMC_FIXUP("V10016", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc, + MMC_QUIRK_TRIM_BROKEN), + ++ /* ++ * On some Kingston SD cards, multiple erases of less than 64 ++ * sectors can cause corruption. ++ */ ++ MMC_FIXUP("SD16G", 0x41, 0x3432, add_quirk, MMC_QUIRK_ERASE_BROKEN), ++ MMC_FIXUP("SD32G", 0x41, 0x3432, add_quirk, MMC_QUIRK_ERASE_BROKEN), ++ MMC_FIXUP("SD64G", 0x41, 0x3432, add_quirk, MMC_QUIRK_ERASE_BROKEN), ++ + END_FIXUP + }; + diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig -index 5755b69f2f728ffb829f257c2016a8965ce19c93..d657e99b7b5a9218cd37dd529ca08eef8c681981 100644 +index 5755b69f2f728ffb829f257c2016a8965ce19c93..267a5be5b029603fcb0a30d59c9c44784b6633d9 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -4,6 +4,35 @@ comment "MMC/SD/SDIO Host Controller Drivers" -+config MMC_BCM2835 ++config MMC_BCM2835_MMC + tristate "MMC support on BCM2835" + depends on MACH_BCM2708 || MACH_BCM2709 || ARCH_BCM2835 + help @@ -67843,7 +68284,7 @@ index 5755b69f2f728ffb829f257c2016a8965ce19c93..d657e99b7b5a9218cd37dd529ca08eef + +config MMC_BCM2835_DMA + bool "DMA support on BCM2835 Arasan controller" -+ depends on MMC_BCM2835 ++ depends on MMC_BCM2835_MMC + help + Enable DMA support on the Arasan SDHCI controller in Broadcom 2708 + based chips. @@ -67852,7 +68293,7 @@ index 5755b69f2f728ffb829f257c2016a8965ce19c93..d657e99b7b5a9218cd37dd529ca08eef + +config MMC_BCM2835_PIO_DMA_BARRIER + int "Block count limit for PIO transfers" -+ depends on MMC_BCM2835 && MMC_BCM2835_DMA ++ depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA + range 0 256 + default 2 + help @@ -67864,23 +68305,23 @@ index 5755b69f2f728ffb829f257c2016a8965ce19c93..d657e99b7b5a9218cd37dd529ca08eef tristate "ARM AMBA Multimedia Card Interface support" depends on ARM_AMBA diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile -index 4d454711631158559c99a4df7953b17f3b1330d6..b8815fc623d7bba9f1375778daa274febeb32769 100644 +index 4d454711631158559c99a4df7953b17f3b1330d6..b27b702f59ba2b473a9d4da77eb5edb0f8763f03 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o obj-$(CONFIG_MMC_SDHCI_SIRF) += sdhci-sirf.o obj-$(CONFIG_MMC_SDHCI_F_SDH30) += sdhci_f_sdh30.o obj-$(CONFIG_MMC_SDHCI_SPEAR) += sdhci-spear.o -+obj-$(CONFIG_MMC_BCM2835) += bcm2835-mmc.o ++obj-$(CONFIG_MMC_BCM2835_MMC) += bcm2835-mmc.o obj-$(CONFIG_MMC_WBSD) += wbsd.o obj-$(CONFIG_MMC_AU1X) += au1xmmc.o obj-$(CONFIG_MMC_MTK) += mtk-sd.o diff --git a/drivers/mmc/host/bcm2835-mmc.c b/drivers/mmc/host/bcm2835-mmc.c new file mode 100644 -index 0000000000000000000000000000000000000000..4fe8d1fe44578fbefcd48f8c327ba3d03f3d0a2a +index 0000000000000000000000000000000000000000..c4a5e992c6fb4a40b933239350ed4bfc8fb40155 --- /dev/null +++ b/drivers/mmc/host/bcm2835-mmc.c -@@ -0,0 +1,1574 @@ +@@ -0,0 +1,1584 @@ +/* + * BCM2835 MMC host driver. + * @@ -67998,6 +68439,7 @@ index 0000000000000000000000000000000000000000..4fe8d1fe44578fbefcd48f8c327ba3d0 + + bool have_dma; + bool use_dma; ++ bool wait_for_dma; + /*end of DMA part*/ + + int max_delay; /* maximum length of time spent waiting */ @@ -68224,6 +68666,8 @@ index 0000000000000000000000000000000000000000..4fe8d1fe44578fbefcd48f8c327ba3d0 + + spin_lock_irqsave(&host->lock, flags); + ++ host->use_dma = false; ++ + if (host->data && !(host->data->flags & MMC_DATA_WRITE)) { + /* otherwise handled in SDHCI IRQ */ + dma_chan = host->dma_chan_rxtx; @@ -68234,6 +68678,9 @@ index 0000000000000000000000000000000000000000..4fe8d1fe44578fbefcd48f8c327ba3d0 + dir_data); + + bcm2835_mmc_finish_data(host); ++ } else if (host->wait_for_dma) { ++ host->wait_for_dma = false; ++ tasklet_schedule(&host->finish_tasklet); + } + + spin_unlock_irqrestore(&host->lock, flags); @@ -68573,6 +69020,7 @@ index 0000000000000000000000000000000000000000..4fe8d1fe44578fbefcd48f8c327ba3d0 + mod_timer(&host->timer, timeout); + + host->cmd = cmd; ++ host->use_dma = false; + + bcm2835_mmc_prepare_data(host, cmd); + @@ -68642,8 +69090,11 @@ index 0000000000000000000000000000000000000000..4fe8d1fe44578fbefcd48f8c327ba3d0 + } + + bcm2835_mmc_send_command(host, data->stop); -+ } else ++ } else if (host->use_dma) { ++ host->wait_for_dma = true; ++ } else { + tasklet_schedule(&host->finish_tasklet); ++ } +} + +static void bcm2835_mmc_finish_command(struct bcm2835_host *host) @@ -69237,14 +69688,14 @@ index 0000000000000000000000000000000000000000..4fe8d1fe44578fbefcd48f8c327ba3d0 + if (ret == 0) { + host->dma_cfg_rx = cfg; + -+ host->use_dma = true; ++ host->have_dma = true; + } else { + pr_err("%s: unable to configure DMA channel. " -+ "Faling back to PIO\n", ++ "Falling back to PIO\n", + mmc_hostname(mmc)); + dma_release_channel(host->dma_chan_rxtx); + host->dma_chan_rxtx = NULL; -+ host->use_dma = false; ++ host->have_dma = false; + } + } +#endif @@ -69455,11 +69906,24 @@ index 0000000000000000000000000000000000000000..4fe8d1fe44578fbefcd48f8c327ba3d0 +MODULE_DESCRIPTION("BCM2835 SDHCI driver"); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Gellert Weisz"); +diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h +index 46c73e97e61f08a41d9753079345f5965caebbc5..388c551ed11e9d06ea1c25b6553d47a8d668953a 100644 +--- a/include/linux/mmc/card.h ++++ b/include/linux/mmc/card.h +@@ -269,6 +269,8 @@ struct mmc_card { + #define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */ + #define MMC_QUIRK_BROKEN_HPI (1<<13) /* Disable broken HPI support */ + ++#define MMC_QUIRK_ERASE_BROKEN (1<<31) /* Skip erase */ ++ + bool reenable_cmdq; /* Re-enable Command Queue */ + + unsigned int erase_size; /* erase size in sectors */ -From f2db02848cd70f0722f41acb56363971ee9c4729 Mon Sep 17 00:00:00 2001 +From 2effda8db6e55c7b4c9edad900cfddfd9e2597bc Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 25 Mar 2015 17:49:47 +0000 -Subject: [PATCH 039/199] Adding bcm2835-sdhost driver, and an overlay to +Subject: [PATCH 044/129] Adding bcm2835-sdhost driver, and an overlay to enable it BCM2835 has two SD card interfaces. This driver uses the other one. @@ -69633,7 +70097,7 @@ Signed-off-by: Phil Elwell create mode 100644 drivers/mmc/host/bcm2835-sdhost.c diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig -index d657e99b7b5a9218cd37dd529ca08eef8c681981..64bd7825131d3dcb003e7ece581b8d599a717b31 100644 +index 267a5be5b029603fcb0a30d59c9c44784b6633d9..dc41121c101e2ac6fe000fe2ab556561a340b78f 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -33,6 +33,16 @@ config MMC_BCM2835_PIO_DMA_BARRIER @@ -69654,13 +70118,13 @@ index d657e99b7b5a9218cd37dd529ca08eef8c681981..64bd7825131d3dcb003e7ece581b8d59 tristate "ARM AMBA Multimedia Card Interface support" depends on ARM_AMBA diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile -index b8815fc623d7bba9f1375778daa274febeb32769..cd3a47d8965958ccf3ac3d186a05bbd437494154 100644 +index b27b702f59ba2b473a9d4da77eb5edb0f8763f03..9ba643d3b2e12960f5ce4b0eb5d75c1c360980ce 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_MMC_SDHCI_SIRF) += sdhci-sirf.o obj-$(CONFIG_MMC_SDHCI_F_SDH30) += sdhci_f_sdh30.o obj-$(CONFIG_MMC_SDHCI_SPEAR) += sdhci-spear.o - obj-$(CONFIG_MMC_BCM2835) += bcm2835-mmc.o + obj-$(CONFIG_MMC_BCM2835_MMC) += bcm2835-mmc.o +obj-$(CONFIG_MMC_BCM2835_SDHOST) += bcm2835-sdhost.o obj-$(CONFIG_MMC_WBSD) += wbsd.o obj-$(CONFIG_MMC_AU1X) += au1xmmc.o @@ -71865,10 +72329,10 @@ index 0000000000000000000000000000000000000000..9c6f199a7830959f31012d86bc1f8b1a +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Phil Elwell"); -From f310a1afb6420cc8453e79412d81022e6a601be2 Mon Sep 17 00:00:00 2001 +From 7f0672a5e885d310c886283944dcbb1ebf4263d0 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Fri, 28 Oct 2016 15:36:43 +0100 -Subject: [PATCH 040/199] vc_mem: Add vc_mem driver for querying firmware +Subject: [PATCH 045/129] vc_mem: Add vc_mem driver for querying firmware memory addresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -72393,10 +72857,10 @@ index 0000000000000000000000000000000000000000..20a475377eb3078ea1ecaef2b24efc35 + +#endif /* _VC_MEM_H */ -From 22acb3e4e7b0bafd9292d9ef30c083ef18b377da Mon Sep 17 00:00:00 2001 +From dd72d988c292f9e7287701360e6af45438b59831 Mon Sep 17 00:00:00 2001 From: Tim Gover Date: Tue, 22 Jul 2014 15:41:04 +0100 -Subject: [PATCH 041/199] vcsm: VideoCore shared memory service for BCM2835 +Subject: [PATCH 046/129] vcsm: VideoCore shared memory service for BCM2835 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -72445,19 +72909,32 @@ and the other VM_FAULT_SIGBUS crashing the user code. Also report when mapping fails. Signed-off-by: popcornmix + +vcsm: Provide new ioctl to clean/invalidate a 2D block + +vcsm: Convert to loading via device tree. + +Signed-off-by: Dave Stevenson + +VCSM: New option to import a DMABUF for VPU use + +Takes a dmabuf, and then calls over to the VPU to wrap +it into a suitable handle. + +Signed-off-by: Dave Stevenson --- drivers/char/Kconfig | 2 + drivers/char/Makefile | 1 + drivers/char/broadcom/Kconfig | 9 + drivers/char/broadcom/Makefile | 1 + drivers/char/broadcom/vc_sm/Makefile | 9 + - drivers/char/broadcom/vc_sm/vc_sm_defs.h | 181 ++ - drivers/char/broadcom/vc_sm/vc_sm_knl.h | 55 + - drivers/char/broadcom/vc_sm/vc_vchi_sm.c | 499 +++++ - drivers/char/broadcom/vc_sm/vc_vchi_sm.h | 82 + - drivers/char/broadcom/vc_sm/vmcs_sm.c | 3222 ++++++++++++++++++++++++++++++ - include/linux/broadcom/vmcs_sm_ioctl.h | 248 +++ - 11 files changed, 4309 insertions(+) + drivers/char/broadcom/vc_sm/vc_sm_defs.h | 237 ++ + drivers/char/broadcom/vc_sm/vc_sm_knl.h | 53 + + drivers/char/broadcom/vc_sm/vc_vchi_sm.c | 516 +++++ + drivers/char/broadcom/vc_sm/vc_vchi_sm.h | 102 + + drivers/char/broadcom/vc_sm/vmcs_sm.c | 3505 ++++++++++++++++++++++++++++++ + include/linux/broadcom/vmcs_sm_ioctl.h | 280 +++ + 11 files changed, 4715 insertions(+) create mode 100644 drivers/char/broadcom/vc_sm/Makefile create mode 100644 drivers/char/broadcom/vc_sm/vc_sm_defs.h create mode 100644 drivers/char/broadcom/vc_sm/vc_sm_knl.h @@ -72529,23 +73006,25 @@ index 0000000000000000000000000000000000000000..19ce263bc273dcdb24ea2b4431e4cafc + vc_vchi_sm.o diff --git a/drivers/char/broadcom/vc_sm/vc_sm_defs.h b/drivers/char/broadcom/vc_sm/vc_sm_defs.h new file mode 100644 -index 0000000000000000000000000000000000000000..c4d5ff718a5ba9071ef87fa4c6cf632486c4d36f +index 0000000000000000000000000000000000000000..de6afe9f65af45582c79a62abd41c688274ad8f2 --- /dev/null +++ b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -@@ -0,0 +1,181 @@ -+/***************************************************************************** -+* Copyright 2011 Broadcom Corporation. All rights reserved. -+* -+* Unless you and Broadcom execute a separate written software license -+* agreement governing use of this software, this software is licensed to you -+* under the terms of the GNU General Public License version 2, available at -+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+* -+* Notwithstanding the above, under no circumstances may you combine this -+* software in any way with any other Broadcom software provided under a -+* license other than the GPL, without Broadcom's express prior written -+* consent. -+*****************************************************************************/ +@@ -0,0 +1,237 @@ ++/* ++ **************************************************************************** ++ * Copyright 2011 Broadcom Corporation. All rights reserved. ++ * ++ * Unless you and Broadcom execute a separate written software license ++ * agreement governing use of this software, this software is licensed to you ++ * under the terms of the GNU General Public License version 2, available at ++ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). ++ * ++ * Notwithstanding the above, under no circumstances may you combine this ++ * software in any way with any other Broadcom software provided under a ++ * license other than the GPL, without Broadcom's express prior written ++ * consent. ++ **************************************************************************** ++ */ + +#ifndef __VC_SM_DEFS_H__INCLUDED__ +#define __VC_SM_DEFS_H__INCLUDED__ @@ -72554,15 +73033,16 @@ index 0000000000000000000000000000000000000000..c4d5ff718a5ba9071ef87fa4c6cf6324 +#define VC_SM_SERVER_NAME MAKE_FOURCC("SMEM") + +/* Maximum message length */ -+#define VC_SM_MAX_MSG_LEN (sizeof(VC_SM_MSG_UNION_T) + \ -+ sizeof(VC_SM_MSG_HDR_T)) -+#define VC_SM_MAX_RSP_LEN (sizeof(VC_SM_MSG_UNION_T)) ++#define VC_SM_MAX_MSG_LEN (sizeof(union vc_sm_msg_union_t) + \ ++ sizeof(struct vc_sm_msg_hdr_t)) ++#define VC_SM_MAX_RSP_LEN (sizeof(union vc_sm_msg_union_t)) + +/* Resource name maximum size */ +#define VC_SM_RESOURCE_NAME 32 + -+/* All message types supported for HOST->VC direction */ -+typedef enum { ++enum vc_sm_msg_type { ++ /* Message types supported for HOST->VC direction */ ++ + /* Allocate shared memory block */ + VC_SM_MSG_TYPE_ALLOC, + /* Lock allocated shared memory block */ @@ -72580,28 +73060,42 @@ index 0000000000000000000000000000000000000000..c4d5ff718a5ba9071ef87fa4c6cf6324 + + /* A previously applied action will need to be reverted */ + VC_SM_MSG_TYPE_ACTION_CLEAN, ++ ++ /* ++ * Import a physical address and wrap into a MEM_HANDLE_T. ++ * Release with VC_SM_MSG_TYPE_FREE. ++ */ ++ VC_SM_MSG_TYPE_IMPORT, ++ ++ /* Message types supported for VC->HOST direction */ ++ ++ /* ++ * VC has finished with an imported memory allocation. ++ * Release any Linux reference counts on the underlying block. ++ */ ++ VC_SM_MSG_TYPE_RELEASED, ++ + VC_SM_MSG_TYPE_MAX -+} VC_SM_MSG_TYPE; ++}; + +/* Type of memory to be allocated */ -+typedef enum { ++enum vc_sm_alloc_type_t { + VC_SM_ALLOC_CACHED, + VC_SM_ALLOC_NON_CACHED, -+ -+} VC_SM_ALLOC_TYPE_T; ++}; + +/* Message header for all messages in HOST->VC direction */ -+typedef struct { ++struct vc_sm_msg_hdr_t { + int32_t type; + uint32_t trans_id; + uint8_t body[0]; + -+} VC_SM_MSG_HDR_T; ++}; + +/* Request to allocate memory (HOST->VC) */ -+typedef struct { ++struct vc_sm_alloc_t { + /* type of memory to allocate */ -+ VC_SM_ALLOC_TYPE_T type; ++ enum vc_sm_alloc_type_t type; + /* byte amount of data to allocate per unit */ + uint32_t base_unit; + /* number of unit to allocate */ @@ -72613,126 +73107,167 @@ index 0000000000000000000000000000000000000000..c4d5ff718a5ba9071ef87fa4c6cf6324 + /* resource name (for easier tracking on vc side) */ + char name[VC_SM_RESOURCE_NAME]; + -+} VC_SM_ALLOC_T; ++}; + +/* Result of a requested memory allocation (VC->HOST) */ -+typedef struct { ++struct vc_sm_alloc_result_t { + /* Transaction identifier */ + uint32_t trans_id; + + /* Resource handle */ + uint32_t res_handle; + /* Pointer to resource buffer */ -+ void *res_mem; ++ uint32_t res_mem; + /* Resource base size (bytes) */ + uint32_t res_base_size; + /* Resource number */ + uint32_t res_num; + -+} VC_SM_ALLOC_RESULT_T; ++}; + +/* Request to free a previously allocated memory (HOST->VC) */ -+typedef struct { ++struct vc_sm_free_t { + /* Resource handle (returned from alloc) */ + uint32_t res_handle; + /* Resource buffer (returned from alloc) */ -+ void *res_mem; ++ uint32_t res_mem; + -+} VC_SM_FREE_T; ++}; + +/* Request to lock a previously allocated memory (HOST->VC) */ -+typedef struct { ++struct vc_sm_lock_unlock_t { + /* Resource handle (returned from alloc) */ + uint32_t res_handle; + /* Resource buffer (returned from alloc) */ -+ void *res_mem; ++ uint32_t res_mem; + -+} VC_SM_LOCK_UNLOCK_T; ++}; + +/* Request to resize a previously allocated memory (HOST->VC) */ -+typedef struct { ++struct vc_sm_resize_t { + /* Resource handle (returned from alloc) */ + uint32_t res_handle; + /* Resource buffer (returned from alloc) */ -+ void *res_mem; ++ uint32_t res_mem; + /* Resource *new* size requested (bytes) */ + uint32_t res_new_size; + -+} VC_SM_RESIZE_T; ++}; + +/* Result of a requested memory lock (VC->HOST) */ -+typedef struct { ++struct vc_sm_lock_result_t { + /* Transaction identifier */ + uint32_t trans_id; + + /* Resource handle */ + uint32_t res_handle; + /* Pointer to resource buffer */ -+ void *res_mem; -+ /* Pointer to former resource buffer if the memory -+ * was reallocated */ -+ void *res_old_mem; ++ uint32_t res_mem; ++ /* ++ * Pointer to former resource buffer if the memory ++ * was reallocated ++ */ ++ uint32_t res_old_mem; + -+} VC_SM_LOCK_RESULT_T; ++}; + +/* Generic result for a request (VC->HOST) */ -+typedef struct { ++struct vc_sm_result_t { + /* Transaction identifier */ + uint32_t trans_id; + + int32_t success; + -+} VC_SM_RESULT_T; ++}; + +/* Request to revert a previously applied action (HOST->VC) */ -+typedef struct { ++struct vc_sm_action_clean_t { + /* Action of interest */ -+ VC_SM_MSG_TYPE res_action; ++ enum vc_sm_msg_type res_action; + /* Transaction identifier for the action of interest */ + uint32_t action_trans_id; + -+} VC_SM_ACTION_CLEAN_T; ++}; + +/* Request to remove all data associated with a given allocator (HOST->VC) */ -+typedef struct { ++struct vc_sm_free_all_t { + /* Allocator identifier */ + uint32_t allocator; ++}; + -+} VC_SM_FREE_ALL_T; ++/* Request to import memory (HOST->VC) */ ++struct vc_sm_import { ++ /* type of memory to allocate */ ++ enum vc_sm_alloc_type_t type; ++ /* pointer to the VC (ie physical) address of the allocated memory */ ++ uint32_t addr; ++ /* size of buffer */ ++ uint32_t size; ++ /* opaque handle returned in RELEASED messages */ ++ int32_t kernel_id; ++ /* Allocator identifier */ ++ uint32_t allocator; ++ /* resource name (for easier tracking on vc side) */ ++ char name[VC_SM_RESOURCE_NAME]; ++}; ++ ++/* Result of a requested memory import (VC->HOST) */ ++struct vc_sm_import_result { ++ /* Transaction identifier */ ++ uint32_t trans_id; ++ ++ /* Resource handle */ ++ uint32_t res_handle; ++}; ++ ++/* Notification that VC has finished with an allocation (VC->HOST) */ ++struct vc_sm_released { ++ /* pointer to the VC (ie physical) address of the allocated memory */ ++ uint32_t addr; ++ /* size of buffer */ ++ uint32_t size; ++ /* opaque handle returned in RELEASED messages */ ++ int32_t kernel_id; ++}; + +/* Union of ALL messages */ -+typedef union { -+ VC_SM_ALLOC_T alloc; -+ VC_SM_ALLOC_RESULT_T alloc_result; -+ VC_SM_FREE_T free; -+ VC_SM_ACTION_CLEAN_T action_clean; -+ VC_SM_RESIZE_T resize; -+ VC_SM_LOCK_RESULT_T lock_result; -+ VC_SM_RESULT_T result; -+ VC_SM_FREE_ALL_T free_all; -+ -+} VC_SM_MSG_UNION_T; ++union vc_sm_msg_union_t { ++ struct vc_sm_alloc_t alloc; ++ struct vc_sm_alloc_result_t alloc_result; ++ struct vc_sm_free_t free; ++ struct vc_sm_lock_unlock_t lock_unlock; ++ struct vc_sm_action_clean_t action_clean; ++ struct vc_sm_resize_t resize; ++ struct vc_sm_lock_result_t lock_result; ++ struct vc_sm_result_t result; ++ struct vc_sm_free_all_t free_all; ++ struct vc_sm_import import; ++ struct vc_sm_import_result import_result; ++ struct vc_sm_released released; ++}; + +#endif /* __VC_SM_DEFS_H__INCLUDED__ */ diff --git a/drivers/char/broadcom/vc_sm/vc_sm_knl.h b/drivers/char/broadcom/vc_sm/vc_sm_knl.h new file mode 100644 -index 0000000000000000000000000000000000000000..965f9a209a025202fea8065d3947c36f4fa43d0a +index 0000000000000000000000000000000000000000..f7f74750d8358779c61dfcd6fc841aa1789a2c5e --- /dev/null +++ b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -@@ -0,0 +1,55 @@ -+/***************************************************************************** -+* Copyright 2011 Broadcom Corporation. All rights reserved. -+* -+* Unless you and Broadcom execute a separate written software license -+* agreement governing use of this software, this software is licensed to you -+* under the terms of the GNU General Public License version 2, available at -+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+* -+* Notwithstanding the above, under no circumstances may you combine this -+* software in any way with any other Broadcom software provided under a -+* license other than the GPL, without Broadcom's express prior written -+* consent. -+*****************************************************************************/ +@@ -0,0 +1,53 @@ ++/* ++ **************************************************************************** ++ * Copyright 2011 Broadcom Corporation. All rights reserved. ++ * ++ * Unless you and Broadcom execute a separate written software license ++ * agreement governing use of this software, this software is licensed to you ++ * under the terms of the GNU General Public License version 2, available at ++ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). ++ * ++ * Notwithstanding the above, under no circumstances may you combine this ++ * software in any way with any other Broadcom software provided under a ++ * license other than the GPL, without Broadcom's express prior written ++ * consent. ++ **************************************************************************** ++ */ + +#ifndef __VC_SM_KNL_H__INCLUDED__ +#define __VC_SM_KNL_H__INCLUDED__ @@ -72742,58 +73277,56 @@ index 0000000000000000000000000000000000000000..965f9a209a025202fea8065d3947c36f +#endif + +/* Type of memory to be locked (ie mapped) */ -+typedef enum { ++enum vc_sm_lock_cache_mode { + VC_SM_LOCK_CACHED, + VC_SM_LOCK_NON_CACHED, ++}; + -+} VC_SM_LOCK_CACHE_MODE_T; ++/* Allocate a shared memory handle and block. */ ++int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle); + -+/* Allocate a shared memory handle and block. -+*/ -+int vc_sm_alloc(VC_SM_ALLOC_T *alloc, int *handle); -+ -+/* Free a previously allocated shared memory handle and block. -+*/ ++/* Free a previously allocated shared memory handle and block. */ +int vc_sm_free(int handle); + -+/* Lock a memory handle for use by kernel. -+*/ -+int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, -+ long unsigned int *data); ++/* Lock a memory handle for use by kernel. */ ++int vc_sm_lock(int handle, enum vc_sm_lock_cache_mode mode, ++ unsigned long *data); + -+/* Unlock a memory handle in use by kernel. -+*/ ++/* Unlock a memory handle in use by kernel. */ +int vc_sm_unlock(int handle, int flush, int no_vc_unlock); + -+/* Get an internal resource handle mapped from the external one. -+*/ ++/* Get an internal resource handle mapped from the external one. */ +int vc_sm_int_handle(int handle); + -+/* Map a shared memory region for use by kernel. -+*/ -+int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, -+ long unsigned int *data); ++/* Map a shared memory region for use by kernel. */ ++int vc_sm_map(int handle, unsigned int sm_addr, ++ enum vc_sm_lock_cache_mode mode, unsigned long *data); ++ ++/* Import a block of memory into the GPU space. */ ++int vc_sm_import_dmabuf(struct dma_buf *dmabuf, int *handle); + +#endif /* __VC_SM_KNL_H__INCLUDED__ */ diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c new file mode 100644 -index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f73a18a70 +index 0000000000000000000000000000000000000000..f8b909a09adb0743ed5d55dadf8fbf2fef055197 --- /dev/null +++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -@@ -0,0 +1,499 @@ -+/***************************************************************************** -+* Copyright 2011-2012 Broadcom Corporation. All rights reserved. -+* -+* Unless you and Broadcom execute a separate written software license -+* agreement governing use of this software, this software is licensed to you -+* under the terms of the GNU General Public License version 2, available at -+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+* -+* Notwithstanding the above, under no circumstances may you combine this -+* software in any way with any other Broadcom software provided under a -+* license other than the GPL, without Broadcom's express prior written -+* consent. -+*****************************************************************************/ +@@ -0,0 +1,516 @@ ++/* ++ **************************************************************************** ++ * Copyright 2011-2012 Broadcom Corporation. All rights reserved. ++ * ++ * Unless you and Broadcom execute a separate written software license ++ * agreement governing use of this software, this software is licensed to you ++ * under the terms of the GNU General Public License version 2, available at ++ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). ++ * ++ * Notwithstanding the above, under no circumstances may you combine this ++ * software in any way with any other Broadcom software provided under a ++ * license other than the GPL, without Broadcom's express prior written ++ * consent. ++ **************************************************************************** ++ */ + +/* ---- Include Files ----------------------------------------------------- */ +#include @@ -72866,11 +73399,11 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + +static struct +sm_cmd_rsp_blk *vc_vchi_cmd_create(struct sm_instance *instance, -+ VC_SM_MSG_TYPE id, void *msg, ++ enum vc_sm_msg_type id, void *msg, + uint32_t size, int wait) +{ + struct sm_cmd_rsp_blk *blk; -+ VC_SM_MSG_HDR_T *hdr; ++ struct vc_sm_msg_hdr_t *hdr; + + if (down_interruptible(&instance->free_sema)) { + blk = kmalloc(sizeof(*blk), GFP_KERNEL); @@ -72892,7 +73425,7 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + blk->wait = wait; + blk->length = sizeof(*hdr) + size; + -+ hdr = (VC_SM_MSG_HDR_T *) blk->msg; ++ hdr = (struct vc_sm_msg_hdr_t *) blk->msg; + hdr->type = id; + mutex_lock(&instance->lock); + hdr->trans_id = blk->id = ++instance->trans_id; @@ -72922,7 +73455,7 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f +{ + struct sm_instance *instance = arg; + struct sm_cmd_rsp_blk *cmd = NULL, *cmd_tmp; -+ VC_SM_RESULT_T *reply; ++ struct vc_sm_result_t *reply; + uint32_t reply_len; + int32_t status; + int svc_use = 1; @@ -73038,7 +73571,7 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + } +} + -+VC_VCHI_SM_HANDLE_T vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, ++struct sm_instance *vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, + VCHI_CONNECTION_T **vchi_connections, + uint32_t num_connections) +{ @@ -73108,7 +73641,8 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + set_user_nice(instance->io_thread, -10); + wake_up_process(instance->io_thread); + -+ pr_debug("%s: success - instance 0x%x", __func__, (unsigned)instance); ++ pr_debug("%s: success - instance 0x%x", __func__, ++ (unsigned int)instance); + return instance; + +err_close_services: @@ -73122,7 +73656,7 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + return NULL; +} + -+int vc_vchi_sm_stop(VC_VCHI_SM_HANDLE_T *handle) ++int vc_vchi_sm_stop(struct sm_instance **handle) +{ + struct sm_instance *instance; + uint32_t i; @@ -73142,6 +73676,7 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + /* Close all VCHI service connections */ + for (i = 0; i < instance->num_connections; i++) { + int32_t success; ++ + vchi_service_use(instance->vchi_handle[i]); + + success = vchi_service_close(instance->vchi_handle[i]); @@ -73156,8 +73691,8 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + return -EINVAL; +} + -+int vc_vchi_sm_send_msg(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_MSG_TYPE msg_id, ++int vc_vchi_sm_send_msg(struct sm_instance *handle, ++ enum vc_sm_msg_type msg_id, + void *msg, uint32_t msg_size, + void *result, uint32_t result_size, + uint32_t *cur_trans_id, uint8_t wait_reply) @@ -73216,7 +73751,8 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + if (result && result_size) { + memcpy(result, cmd_blk->msg, result_size); + } else { -+ VC_SM_RESULT_T *res = (VC_SM_RESULT_T *) cmd_blk->msg; ++ struct vc_sm_result_t *res = ++ (struct vc_sm_result_t *) cmd_blk->msg; + status = (res->success == 0) ? 0 : -ENXIO; + } + @@ -73227,32 +73763,34 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + return status; +} + -+int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, VC_SM_ALLOC_T *msg, -+ VC_SM_ALLOC_RESULT_T *result, uint32_t *cur_trans_id) ++int vc_vchi_sm_alloc(struct sm_instance *handle, struct vc_sm_alloc_t *msg, ++ struct vc_sm_alloc_result_t *result, ++ uint32_t *cur_trans_id) +{ + return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_ALLOC, + msg, sizeof(*msg), result, sizeof(*result), + cur_trans_id, 1); +} + -+int vc_vchi_sm_free(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_FREE_T *msg, uint32_t *cur_trans_id) ++int vc_vchi_sm_free(struct sm_instance *handle, ++ struct vc_sm_free_t *msg, uint32_t *cur_trans_id) +{ + return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_FREE, + msg, sizeof(*msg), 0, 0, cur_trans_id, 0); +} + -+int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_LOCK_UNLOCK_T *msg, -+ VC_SM_LOCK_RESULT_T *result, uint32_t *cur_trans_id) ++int vc_vchi_sm_lock(struct sm_instance *handle, ++ struct vc_sm_lock_unlock_t *msg, ++ struct vc_sm_lock_result_t *result, ++ uint32_t *cur_trans_id) +{ + return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_LOCK, + msg, sizeof(*msg), result, sizeof(*result), + cur_trans_id, 1); +} + -+int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_LOCK_UNLOCK_T *msg, ++int vc_vchi_sm_unlock(struct sm_instance *handle, ++ struct vc_sm_lock_unlock_t *msg, + uint32_t *cur_trans_id, uint8_t wait_reply) +{ + return vc_vchi_sm_send_msg(handle, wait_reply ? @@ -73262,43 +73800,55 @@ index 0000000000000000000000000000000000000000..76abd126c4617b6310fcf0ebd7ab1d5f + wait_reply); +} + -+int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, VC_SM_RESIZE_T *msg, -+ uint32_t *cur_trans_id) ++int vc_vchi_sm_resize(struct sm_instance *handle, struct vc_sm_resize_t *msg, ++ uint32_t *cur_trans_id) +{ + return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_RESIZE, + msg, sizeof(*msg), 0, 0, cur_trans_id, 1); +} + -+int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle) ++int vc_vchi_sm_walk_alloc(struct sm_instance *handle) +{ + return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_WALK_ALLOC, + 0, 0, 0, 0, 0, 0); +} + -+int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, VC_SM_ACTION_CLEAN_T *msg) ++int vc_vchi_sm_clean_up(struct sm_instance *handle, ++ struct vc_sm_action_clean_t *msg) +{ + return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_ACTION_CLEAN, + msg, sizeof(*msg), 0, 0, 0, 0); +} ++ ++int vc_vchi_sm_import(struct sm_instance *handle, struct vc_sm_import *msg, ++ struct vc_sm_import_result *result, ++ uint32_t *cur_trans_id) ++{ ++ return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_IMPORT, ++ msg, sizeof(*msg), result, sizeof(*result), ++ cur_trans_id, 1); ++} diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h new file mode 100644 -index 0000000000000000000000000000000000000000..5e279f5a95fac7227cea15941bf0570ddc2b0886 +index 0000000000000000000000000000000000000000..abe4ed15836f2be756083d3fdb4edb544dacc1a6 --- /dev/null +++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -@@ -0,0 +1,82 @@ -+/***************************************************************************** -+* Copyright 2011 Broadcom Corporation. All rights reserved. -+* -+* Unless you and Broadcom execute a separate written software license -+* agreement governing use of this software, this software is licensed to you -+* under the terms of the GNU General Public License version 2, available at -+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+* -+* Notwithstanding the above, under no circumstances may you combine this -+* software in any way with any other Broadcom software provided under a -+* license other than the GPL, without Broadcom's express prior written -+* consent. -+*****************************************************************************/ +@@ -0,0 +1,102 @@ ++/* ++ **************************************************************************** ++ * Copyright 2011 Broadcom Corporation. All rights reserved. ++ * ++ * Unless you and Broadcom execute a separate written software license ++ * agreement governing use of this software, this software is licensed to you ++ * under the terms of the GNU General Public License version 2, available at ++ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). ++ * ++ * Notwithstanding the above, under no circumstances may you combine this ++ * software in any way with any other Broadcom software provided under a ++ * license other than the GPL, without Broadcom's express prior written ++ * consent. ++ **************************************************************************** ++ */ + +#ifndef __VC_VCHI_SM_H__INCLUDED__ +#define __VC_VCHI_SM_H__INCLUDED__ @@ -73307,86 +73857,106 @@ index 0000000000000000000000000000000000000000..5e279f5a95fac7227cea15941bf0570d + +#include "vc_sm_defs.h" + -+/* Forward declare. -+*/ -+typedef struct sm_instance *VC_VCHI_SM_HANDLE_T; ++/* ++ * Forward declare. ++ */ ++struct sm_instance; + -+/* Initialize the shared memory service, opens up vchi connection to talk to it. -+*/ -+VC_VCHI_SM_HANDLE_T vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, ++/* ++ * Initialize the shared memory service, opens up vchi connection to talk to it. ++ */ ++struct sm_instance *vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, + VCHI_CONNECTION_T **vchi_connections, + uint32_t num_connections); + -+/* Terminates the shared memory service. -+*/ -+int vc_vchi_sm_stop(VC_VCHI_SM_HANDLE_T *handle); ++/* ++ * Terminates the shared memory service. ++ */ ++int vc_vchi_sm_stop(struct sm_instance **handle); + -+/* Ask the shared memory service to allocate some memory on videocre and -+** return the result of this allocation (which upon success will be a pointer -+** to some memory in videocore space). -+*/ -+int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_ALLOC_T *alloc, -+ VC_SM_ALLOC_RESULT_T *alloc_result, uint32_t *trans_id); ++/* ++ * Ask the shared memory service to allocate some memory on videocre and ++ * return the result of this allocation (which upon success will be a pointer ++ * to some memory in videocore space). ++ */ ++int vc_vchi_sm_alloc(struct sm_instance *handle, struct vc_sm_alloc_t *alloc, ++ struct vc_sm_alloc_result_t *alloc_result, ++ uint32_t *trans_id); + -+/* Ask the shared memory service to free up some memory that was previously -+** allocated by the vc_vchi_sm_alloc function call. -+*/ -+int vc_vchi_sm_free(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_FREE_T *free, uint32_t *trans_id); ++/* ++ * Ask the shared memory service to free up some memory that was previously ++ * allocated by the vc_vchi_sm_alloc function call. ++ */ ++int vc_vchi_sm_free(struct sm_instance *handle, ++ struct vc_sm_free_t *free, uint32_t *trans_id); + -+/* Ask the shared memory service to lock up some memory that was previously -+** allocated by the vc_vchi_sm_alloc function call. -+*/ -+int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_LOCK_UNLOCK_T *lock_unlock, -+ VC_SM_LOCK_RESULT_T *lock_result, uint32_t *trans_id); ++/* ++ * Ask the shared memory service to lock up some memory that was previously ++ * allocated by the vc_vchi_sm_alloc function call. ++ */ ++int vc_vchi_sm_lock(struct sm_instance *handle, ++ struct vc_sm_lock_unlock_t *lock_unlock, ++ struct vc_sm_lock_result_t *lock_result, ++ uint32_t *trans_id); + -+/* Ask the shared memory service to unlock some memory that was previously -+** allocated by the vc_vchi_sm_alloc function call. -+*/ -+int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_LOCK_UNLOCK_T *lock_unlock, ++/* ++ * Ask the shared memory service to unlock some memory that was previously ++ * allocated by the vc_vchi_sm_alloc function call. ++ */ ++int vc_vchi_sm_unlock(struct sm_instance *handle, ++ struct vc_sm_lock_unlock_t *lock_unlock, + uint32_t *trans_id, uint8_t wait_reply); + -+/* Ask the shared memory service to resize some memory that was previously -+** allocated by the vc_vchi_sm_alloc function call. -+*/ -+int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_RESIZE_T *resize, uint32_t *trans_id); ++/* ++ * Ask the shared memory service to resize some memory that was previously ++ * allocated by the vc_vchi_sm_alloc function call. ++ */ ++int vc_vchi_sm_resize(struct sm_instance *handle, ++ struct vc_sm_resize_t *resize, uint32_t *trans_id); + -+/* Walk the allocated resources on the videocore side, the allocation will -+** show up in the log. This is purely for debug/information and takes no -+** specific actions. -+*/ -+int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle); ++/* ++ * Walk the allocated resources on the videocore side, the allocation will ++ * show up in the log. This is purely for debug/information and takes no ++ * specific actions. ++ */ ++int vc_vchi_sm_walk_alloc(struct sm_instance *handle); + -+/* Clean up following a previously interrupted action which left the system -+** in a bad state of some sort. -+*/ -+int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, -+ VC_SM_ACTION_CLEAN_T *action_clean); ++/* ++ * Clean up following a previously interrupted action which left the system ++ * in a bad state of some sort. ++ */ ++int vc_vchi_sm_clean_up(struct sm_instance *handle, ++ struct vc_sm_action_clean_t *action_clean); ++ ++/* ++ * Import a contiguous block of memory and wrap it in a GPU MEM_HANDLE_T. ++ */ ++int vc_vchi_sm_import(struct sm_instance *handle, struct vc_sm_import *msg, ++ struct vc_sm_import_result *result, ++ uint32_t *cur_trans_id); + +#endif /* __VC_VCHI_SM_H__INCLUDED__ */ diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c new file mode 100644 -index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd4203179500 +index 0000000000000000000000000000000000000000..034ae2f27f870621af9f49453501f1cde051f32a --- /dev/null +++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -0,0 +1,3222 @@ -+/***************************************************************************** -+* Copyright 2011-2012 Broadcom Corporation. All rights reserved. -+* -+* Unless you and Broadcom execute a separate written software license -+* agreement governing use of this software, this software is licensed to you -+* under the terms of the GNU General Public License version 2, available at -+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+* -+* Notwithstanding the above, under no circumstances may you combine this -+* software in any way with any other Broadcom software provided under a -+* license other than the GPL, without Broadcom's express prior written -+* consent. -+*****************************************************************************/ +@@ -0,0 +1,3505 @@ ++/* ++ **************************************************************************** ++ * Copyright 2011-2012 Broadcom Corporation. All rights reserved. ++ * ++ * Unless you and Broadcom execute a separate written software license ++ * agreement governing use of this software, this software is licensed to you ++ * under the terms of the GNU General Public License version 2, available at ++ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). ++ * ++ * Notwithstanding the above, under no circumstances may you combine this ++ * software in any way with any other Broadcom software provided under a ++ * license other than the GPL, without Broadcom's express prior written ++ * consent. ++ **************************************************************************** ++ */ + +/* ---- Include Files ----------------------------------------------------- */ + @@ -73395,6 +73965,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +#include +#include +#include ++#include +#include +#include +#include @@ -73403,6 +73974,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +#include +#include +#include ++#include ++#include +#include +#include +#include @@ -73421,6 +73994,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +/* ---- Private Constants and Types --------------------------------------- */ + +#define DEVICE_NAME "vcsm" ++#define DRIVER_NAME "bcm2835-vcsm" +#define DEVICE_MINOR 0 + +#define VC_SM_DIR_ROOT_NAME "vc-smem" @@ -73431,9 +74005,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +#define VC_SM_DEBUG "debug" +#define VC_SM_WRITE_BUF_SIZE 128 + -+/* Statistics tracked per resource and globally. -+*/ -+enum SM_STATS_T { ++/* Statistics tracked per resource and globally. */ ++enum sm_stats_t { + /* Attempt. */ + ALLOC, + FREE, @@ -73442,6 +74015,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + MAP, + FLUSH, + INVALID, ++ IMPORT, + + END_ATTEMPT, + @@ -73453,6 +74027,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + MAP_FAIL, + FLUSH_FAIL, + INVALID_FAIL, ++ IMPORT_FAIL, + + END_ALL, + @@ -73466,38 +74041,37 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + "Map", + "Cache Flush", + "Cache Invalidate", ++ "Import", +}; + +typedef int (*VC_SM_SHOW) (struct seq_file *s, void *v); -+struct SM_PDE_T { ++struct sm_pde_t { + VC_SM_SHOW show; /* Debug fs function hookup. */ + struct dentry *dir_entry; /* Debug fs directory entry. */ + void *priv_data; /* Private data */ + +}; + -+/* Single resource allocation tracked for all devices. -+*/ ++/* Single resource allocation tracked for all devices. */ +struct sm_mmap { + struct list_head map_list; /* Linked list of maps. */ + -+ struct SM_RESOURCE_T *resource; /* Pointer to the resource. */ ++ struct sm_resource_t *resource; /* Pointer to the resource. */ + -+ pid_t res_pid; /* PID owning that resource. */ ++ pid_t res_pid; /* PID owning that resource. */ + unsigned int res_vc_hdl; /* Resource handle (videocore). */ + unsigned int res_usr_hdl; /* Resource handle (user). */ + -+ long unsigned int res_addr; /* Mapped virtual address. */ ++ unsigned long res_addr; /* Mapped virtual address. */ + struct vm_area_struct *vma; /* VM area for this mapping. */ -+ unsigned int ref_count; /* Reference count to this vma. */ ++ unsigned int ref_count; /* Reference count to this vma. */ + + /* Used to link maps associated with a resource. */ + struct list_head resource_map_list; +}; + -+/* Single resource allocation tracked for each opened device. -+*/ -+struct SM_RESOURCE_T { ++/* Single resource allocation tracked for each opened device. */ ++struct sm_resource_t { + struct list_head resource_list; /* List of resources. */ + struct list_head global_resource_list; /* Global list of resources. */ + @@ -73510,49 +74084,55 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + void *res_base_mem; /* Resource base memory address. */ + uint32_t res_size; /* Resource size allocated. */ + enum vmcs_sm_cache_e res_cached; /* Resource cache type. */ -+ struct SM_RESOURCE_T *res_shared; /* Shared resource */ ++ struct sm_resource_t *res_shared; /* Shared resource */ + -+ enum SM_STATS_T res_stats[END_ALL]; /* Resource statistics. */ ++ enum sm_stats_t res_stats[END_ALL]; /* Resource statistics. */ + + uint8_t map_count; /* Counter of mappings for this resource. */ + struct list_head map_list; /* Maps associated with a resource. */ + -+ struct SM_PRIV_DATA_T *private; ++ /* DMABUF related fields */ ++ struct dma_buf *dma_buf; ++ struct dma_buf_attachment *attach; ++ struct sg_table *sgt; ++ dma_addr_t dma_addr; ++ ++ struct sm_priv_data_t *private; ++ bool map; /* whether to map pages up front */ +}; + -+/* Private file data associated with each opened device. -+*/ -+struct SM_PRIV_DATA_T { ++/* Private file data associated with each opened device. */ ++struct sm_priv_data_t { + struct list_head resource_list; /* List of resources. */ + + pid_t pid; /* PID of creator. */ + + struct dentry *dir_pid; /* Debug fs entries root. */ -+ struct SM_PDE_T dir_stats; /* Debug fs entries statistics sub-tree. */ -+ struct SM_PDE_T dir_res; /* Debug fs resource sub-tree. */ ++ struct sm_pde_t dir_stats; /* Debug fs entries statistics sub-tree. */ ++ struct sm_pde_t dir_res; /* Debug fs resource sub-tree. */ + + int restart_sys; /* Tracks restart on interrupt. */ -+ VC_SM_MSG_TYPE int_action; /* Interrupted action. */ ++ enum vc_sm_msg_type int_action; /* Interrupted action. */ + uint32_t int_trans_id; /* Interrupted transaction. */ + +}; + -+/* Global state information. -+*/ -+struct SM_STATE_T { -+ VC_VCHI_SM_HANDLE_T sm_handle; /* Handle for videocore service. */ ++/* Global state information. */ ++struct sm_state_t { ++ struct platform_device *pdev; ++ struct sm_instance *sm_handle; /* Handle for videocore service. */ + struct dentry *dir_root; /* Debug fs entries root. */ + struct dentry *dir_alloc; /* Debug fs entries allocations. */ -+ struct SM_PDE_T dir_stats; /* Debug fs entries statistics sub-tree. */ -+ struct SM_PDE_T dir_state; /* Debug fs entries state sub-tree. */ ++ struct sm_pde_t dir_stats; /* Debug fs entries statistics sub-tree. */ ++ struct sm_pde_t dir_state; /* Debug fs entries state sub-tree. */ + struct dentry *debug; /* Debug fs entries debug. */ + + struct mutex map_lock; /* Global map lock. */ + struct list_head map_list; /* List of maps. */ + struct list_head resource_list; /* List of resources. */ + -+ enum SM_STATS_T deceased[END_ALL]; /* Natural termination stats. */ -+ enum SM_STATS_T terminated[END_ALL]; /* Forced termination stats. */ ++ enum sm_stats_t deceased[END_ALL]; /* Natural termination stats. */ ++ enum sm_stats_t terminated[END_ALL]; /* Forced termination stats. */ + uint32_t res_deceased_cnt; /* Natural termination counter. */ + uint32_t res_terminated_cnt; /* Forced termination counter. */ + @@ -73561,7 +74141,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + struct class *sm_class; /* Class. */ + struct device *sm_dev; /* Device. */ + -+ struct SM_PRIV_DATA_T *data_knl; /* Kernel internal data tracking. */ ++ struct sm_priv_data_t *data_knl; /* Kernel internal data tracking. */ + + struct mutex lock; /* Global lock. */ + uint32_t guid; /* GUID (next) tracker. */ @@ -73570,7 +74150,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + +/* ---- Private Variables ----------------------------------------------- */ + -+static struct SM_STATE_T *sm_state; ++static struct sm_state_t *sm_state; +static int sm_inited; + +#if 0 @@ -73582,22 +74162,50 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +}; +#endif + ++typedef void cache_flush_op_fn(const void *, const void *); ++ ++#if defined(CONFIG_CPU_CACHE_V7) ++extern cache_flush_op_fn v7_dma_inv_range; ++extern cache_flush_op_fn v7_dma_clean_range; ++static cache_flush_op_fn * const flushops[4] = ++{ ++ 0, ++ v7_dma_inv_range, ++ v7_dma_clean_range, ++ v7_dma_flush_range, ++}; ++#elif defined(CONFIG_CPU_CACHE_V6) ++extern cache_flush_op_fn v6_dma_inv_range; ++extern cache_flush_op_fn v6_dma_clean_range; ++static cache_flush_op_fn * const flushops[4] = ++{ ++ 0, ++ v6_dma_inv_range, ++ v6_dma_clean_range, ++ v6_dma_flush_range, ++}; ++#else ++#error Unknown cache config ++#endif ++ +/* ---- Private Function Prototypes -------------------------------------- */ + +/* ---- Private Functions ------------------------------------------------ */ + -+static inline unsigned vcaddr_to_pfn(unsigned long vc_addr) ++static inline unsigned int vcaddr_to_pfn(unsigned long vc_addr) +{ + unsigned long pfn = vc_addr & 0x3FFFFFFF; ++ + pfn += mm_vc_mem_phys_addr; + pfn >>= PAGE_SHIFT; + return pfn; +} + -+/* Carries over to the state statistics the statistics once owned by a deceased -+** resource. -+*/ -+static void vc_sm_resource_deceased(struct SM_RESOURCE_T *p_res, int terminated) ++/* ++ * Carries over to the state statistics the statistics once owned by a deceased ++ * resource. ++ */ ++static void vc_sm_resource_deceased(struct sm_resource_t *p_res, int terminated) +{ + if (sm_state != NULL) { + if (p_res != NULL) { @@ -73620,9 +74228,10 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } +} + -+/* Fetch a videocore handle corresponding to a mapping of the pid+address -+** returns 0 (ie NULL) if no such handle exists in the global map. -+*/ ++/* ++ * Fetch a videocore handle corresponding to a mapping of the pid+address ++ * returns 0 (ie NULL) if no such handle exists in the global map. ++ */ +static unsigned int vmcs_sm_vc_handle_from_pid_and_address(unsigned int pid, + unsigned int addr) +{ @@ -73634,8 +74243,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + mutex_lock(&(sm_state->map_lock)); + -+ /* Lookup the resource. -+ */ ++ /* Lookup the resource. */ + if (!list_empty(&sm_state->map_list)) { + list_for_each_entry(map, &sm_state->map_list, map_list) { + if (map->res_pid != pid || map->res_addr != addr) @@ -73653,13 +74261,14 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + mutex_unlock(&(sm_state->map_lock)); + +out: -+ /* Use a debug log here as it may be a valid situation that we query -+ ** for something that is not mapped, we do not want a kernel log each -+ ** time around. -+ ** -+ ** There are other error log that would pop up accordingly if someone -+ ** subsequently tries to use something invalid after being told not to -+ ** use it... ++ /* ++ * Use a debug log here as it may be a valid situation that we query ++ * for something that is not mapped, we do not want a kernel log each ++ * time around. ++ * ++ * There are other error log that would pop up accordingly if someone ++ * subsequently tries to use something invalid after being told not to ++ * use it... + */ + if (handle == 0) { + pr_debug("[%s]: not a valid map (pid %u, addr %x)\n", @@ -73669,9 +74278,10 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return handle; +} + -+/* Fetch a user handle corresponding to a mapping of the pid+address -+** returns 0 (ie NULL) if no such handle exists in the global map. -+*/ ++/* ++ * Fetch a user handle corresponding to a mapping of the pid+address ++ * returns 0 (ie NULL) if no such handle exists in the global map. ++ */ +static unsigned int vmcs_sm_usr_handle_from_pid_and_address(unsigned int pid, + unsigned int addr) +{ @@ -73683,8 +74293,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + mutex_lock(&(sm_state->map_lock)); + -+ /* Lookup the resource. -+ */ ++ /* Lookup the resource. */ + if (!list_empty(&sm_state->map_list)) { + list_for_each_entry(map, &sm_state->map_list, map_list) { + if (map->res_pid != pid || map->res_addr != addr) @@ -73702,7 +74311,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + mutex_unlock(&(sm_state->map_lock)); + +out: -+ /* Use a debug log here as it may be a valid situation that we query ++ /* ++ * Use a debug log here as it may be a valid situation that we query + * for something that is not mapped yet. + * + * There are other error log that would pop up accordingly if someone @@ -73717,9 +74327,10 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} + +#if defined(DO_NOT_USE) -+/* Fetch an address corresponding to a mapping of the pid+handle -+** returns 0 (ie NULL) if no such address exists in the global map. -+*/ ++/* ++ * Fetch an address corresponding to a mapping of the pid+handle ++ * returns 0 (ie NULL) if no such address exists in the global map. ++ */ +static unsigned int vmcs_sm_usr_address_from_pid_and_vc_handle(unsigned int pid, + unsigned int hdl) +{ @@ -73731,8 +74342,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + mutex_lock(&(sm_state->map_lock)); + -+ /* Lookup the resource. -+ */ ++ /* Lookup the resource. */ + if (!list_empty(&sm_state->map_list)) { + list_for_each_entry(map, &sm_state->map_list, map_list) { + if (map->res_pid != pid || map->res_vc_hdl != hdl) @@ -73750,13 +74360,14 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + mutex_unlock(&(sm_state->map_lock)); + +out: -+ /* Use a debug log here as it may be a valid situation that we query -+ ** for something that is not mapped, we do not want a kernel log each -+ ** time around. -+ ** -+ ** There are other error log that would pop up accordingly if someone -+ ** subsequently tries to use something invalid after being told not to -+ ** use it... ++ /* ++ * Use a debug log here as it may be a valid situation that we query ++ * for something that is not mapped, we do not want a kernel log each ++ * time around. ++ * ++ * There are other error log that would pop up accordingly if someone ++ * subsequently tries to use something invalid after being told not to ++ * use it... + */ + if (addr == 0) + pr_debug("[%s]: not a valid map (pid %u, hdl %x)\n", @@ -73766,9 +74377,10 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} +#endif + -+/* Fetch an address corresponding to a mapping of the pid+handle -+** returns 0 (ie NULL) if no such address exists in the global map. -+*/ ++/* ++ * Fetch an address corresponding to a mapping of the pid+handle ++ * returns 0 (ie NULL) if no such address exists in the global map. ++ */ +static unsigned int vmcs_sm_usr_address_from_pid_and_usr_handle(unsigned int + pid, + unsigned int @@ -73782,8 +74394,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + mutex_lock(&(sm_state->map_lock)); + -+ /* Lookup the resource. -+ */ ++ /* Lookup the resource. */ + if (!list_empty(&sm_state->map_list)) { + list_for_each_entry(map, &sm_state->map_list, map_list) { + if (map->res_pid != pid || map->res_usr_hdl != hdl) @@ -73801,7 +74412,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + mutex_unlock(&(sm_state->map_lock)); + +out: -+ /* Use a debug log here as it may be a valid situation that we query ++ /* ++ * Use a debug log here as it may be a valid situation that we query + * for something that is not mapped, we do not want a kernel log each + * time around. + * @@ -73816,19 +74428,16 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return addr; +} + -+/* Adds a resource mapping to the global data list. -+*/ -+static void vmcs_sm_add_map(struct SM_STATE_T *state, -+ struct SM_RESOURCE_T *resource, struct sm_mmap *map) ++/* Adds a resource mapping to the global data list. */ ++static void vmcs_sm_add_map(struct sm_state_t *state, ++ struct sm_resource_t *resource, struct sm_mmap *map) +{ + mutex_lock(&(state->map_lock)); + -+ /* Add to the global list of mappings -+ */ ++ /* Add to the global list of mappings */ + list_add(&map->map_list, &state->map_list); + -+ /* Add to the list of mappings for this resource -+ */ ++ /* Add to the list of mappings for this resource */ + list_add(&map->resource_map_list, &resource->map_list); + resource->map_count++; + @@ -73839,20 +74448,17 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + map->res_usr_hdl, map->res_addr); +} + -+/* Removes a resource mapping from the global data list. -+*/ -+static void vmcs_sm_remove_map(struct SM_STATE_T *state, -+ struct SM_RESOURCE_T *resource, ++/* Removes a resource mapping from the global data list. */ ++static void vmcs_sm_remove_map(struct sm_state_t *state, ++ struct sm_resource_t *resource, + struct sm_mmap *map) +{ + mutex_lock(&(state->map_lock)); + -+ /* Remove from the global list of mappings -+ */ ++ /* Remove from the global list of mappings */ + list_del(&map->map_list); + -+ /* Remove from the list of mapping for this resource -+ */ ++ /* Remove from the list of mapping for this resource */ + list_del(&map->resource_map_list); + if (resource->map_count > 0) + resource->map_count--; @@ -73866,12 +74472,13 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + kfree(map); +} + -+/* Read callback for the global state proc entry. -+*/ ++/* Read callback for the global state proc entry. */ +static int vc_sm_global_state_show(struct seq_file *s, void *v) +{ + struct sm_mmap *map = NULL; ++ struct sm_resource_t *resource = NULL; + int map_count = 0; ++ int resource_count = 0; + + if (sm_state == NULL) + return 0; @@ -73879,11 +74486,44 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + seq_printf(s, "\nVC-ServiceHandle 0x%x\n", + (unsigned int)sm_state->sm_handle); + -+ /* Log all applicable mapping(s). -+ */ ++ /* Log all applicable mapping(s). */ + + mutex_lock(&(sm_state->map_lock)); ++ seq_puts(s, "\nResources\n"); ++ if (!list_empty(&sm_state->resource_list)) { ++ list_for_each_entry(resource, &sm_state->resource_list, ++ global_resource_list) { ++ resource_count++; + ++ seq_printf(s, "\nResource %p\n", ++ resource); ++ seq_printf(s, " PID %u\n", ++ resource->pid); ++ seq_printf(s, " RES_GUID 0x%x\n", ++ resource->res_guid); ++ seq_printf(s, " LOCK_COUNT %u\n", ++ resource->lock_count); ++ seq_printf(s, " REF_COUNT %u\n", ++ resource->ref_count); ++ seq_printf(s, " res_handle 0x%X\n", ++ resource->res_handle); ++ seq_printf(s, " res_base_mem %p\n", ++ resource->res_base_mem); ++ seq_printf(s, " SIZE %d\n", ++ resource->res_size); ++ seq_printf(s, " DMABUF %p\n", ++ resource->dma_buf); ++ seq_printf(s, " ATTACH %p\n", ++ resource->attach); ++ seq_printf(s, " SGT %p\n", ++ resource->sgt); ++ seq_printf(s, " DMA_ADDR 0x%08X\n", ++ resource->dma_addr); ++ } ++ } ++ seq_printf(s, "\n\nTotal resource count: %d\n\n", resource_count); ++ ++ seq_puts(s, "\nMappings\n"); + if (!list_empty(&sm_state->map_list)) { + list_for_each_entry(map, &sm_state->map_list, map_list) { + map_count++; @@ -73898,6 +74538,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + map->res_usr_hdl); + seq_printf(s, " USR-ADDR 0x%lx\n", + map->res_addr); ++ seq_printf(s, " SIZE %d\n", ++ map->resource->res_size); + } + } + @@ -73911,8 +74553,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +{ + int ix; + -+ /* Global state tracked statistics. -+ */ ++ /* Global state tracked statistics. */ + if (sm_state != NULL) { + seq_puts(s, "\nDeceased Resources Statistics\n"); + @@ -73958,24 +74599,22 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} + +#if 0 -+/* Read callback for the statistics proc entry. -+*/ ++/* Read callback for the statistics proc entry. */ +static int vc_sm_statistics_show(struct seq_file *s, void *v) +{ + int ix; -+ struct SM_PRIV_DATA_T *file_data; -+ struct SM_RESOURCE_T *resource; ++ struct sm_priv_data_t *file_data; ++ struct sm_resource_t *resource; + int res_count = 0; -+ struct SM_PDE_T *p_pde; ++ struct sm_pde_t *p_pde; + -+ p_pde = (struct SM_PDE_T *)(s->private); -+ file_data = (struct SM_PRIV_DATA_T *)(p_pde->priv_data); ++ p_pde = (struct sm_pde_t *)(s->private); ++ file_data = (struct sm_priv_data_t *)(p_pde->priv_data); + + if (file_data == NULL) + return 0; + -+ /* Per process statistics. -+ */ ++ /* Per process statistics. */ + + seq_printf(s, "\nStatistics for TGID %d\n", file_data->pid); + @@ -74021,13 +74660,13 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +/* Read callback for the allocation proc entry. */ +static int vc_sm_alloc_show(struct seq_file *s, void *v) +{ -+ struct SM_PRIV_DATA_T *file_data; -+ struct SM_RESOURCE_T *resource; ++ struct sm_priv_data_t *file_data; ++ struct sm_resource_t *resource; + int alloc_count = 0; -+ struct SM_PDE_T *p_pde; ++ struct sm_pde_t *p_pde; + -+ p_pde = (struct SM_PDE_T *)(s->private); -+ file_data = (struct SM_PRIV_DATA_T *)(p_pde->priv_data); ++ p_pde = (struct sm_pde_t *)(s->private); ++ file_data = (struct sm_priv_data_t *)(p_pde->priv_data); + + if (!file_data) + return 0; @@ -74069,9 +74708,9 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + +static int vc_sm_seq_file_show(struct seq_file *s, void *v) +{ -+ struct SM_PDE_T *sm_pde; ++ struct sm_pde_t *sm_pde; + -+ sm_pde = (struct SM_PDE_T *)(s->private); ++ sm_pde = (struct sm_pde_t *)(s->private); + + if (sm_pde && sm_pde->show) + sm_pde->show(s, v); @@ -74091,11 +74730,12 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + .release = single_release, +}; + -+/* Adds a resource to the private data list which tracks all the allocated -+** data. -+*/ -+static void vmcs_sm_add_resource(struct SM_PRIV_DATA_T *privdata, -+ struct SM_RESOURCE_T *resource) ++/* ++ * Adds a resource to the private data list which tracks all the allocated ++ * data. ++ */ ++static void vmcs_sm_add_resource(struct sm_priv_data_t *privdata, ++ struct sm_resource_t *resource) +{ + mutex_lock(&(sm_state->map_lock)); + list_add(&resource->resource_list, &privdata->resource_list); @@ -74107,14 +74747,15 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + resource->res_handle, resource->res_size, resource->res_cached); +} + -+/* Locates a resource and acquire a reference on it. -+** The resource won't be deleted while there is a reference on it. -+*/ -+static struct SM_RESOURCE_T *vmcs_sm_acquire_resource(struct SM_PRIV_DATA_T ++/* ++ * Locates a resource and acquire a reference on it. ++ * The resource won't be deleted while there is a reference on it. ++ */ ++static struct sm_resource_t *vmcs_sm_acquire_resource(struct sm_priv_data_t + *private, + unsigned int res_guid) +{ -+ struct SM_RESOURCE_T *resource, *ret = NULL; ++ struct sm_resource_t *resource, *ret = NULL; + + mutex_lock(&(sm_state->map_lock)); + @@ -74136,13 +74777,14 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Locates a resource and acquire a reference on it. -+** The resource won't be deleted while there is a reference on it. -+*/ -+static struct SM_RESOURCE_T *vmcs_sm_acquire_first_resource( -+ struct SM_PRIV_DATA_T *private) ++/* ++ * Locates a resource and acquire a reference on it. ++ * The resource won't be deleted while there is a reference on it. ++ */ ++static struct sm_resource_t *vmcs_sm_acquire_first_resource( ++ struct sm_priv_data_t *private) +{ -+ struct SM_RESOURCE_T *resource, *ret = NULL; ++ struct sm_resource_t *resource, *ret = NULL; + + mutex_lock(&(sm_state->map_lock)); + @@ -74161,13 +74803,14 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Locates a resource and acquire a reference on it. -+** The resource won't be deleted while there is a reference on it. -+*/ -+static struct SM_RESOURCE_T *vmcs_sm_acquire_global_resource(unsigned int ++/* ++ * Locates a resource and acquire a reference on it. ++ * The resource won't be deleted while there is a reference on it. ++ */ ++static struct sm_resource_t *vmcs_sm_acquire_global_resource(unsigned int + res_guid) +{ -+ struct SM_RESOURCE_T *resource, *ret = NULL; ++ struct sm_resource_t *resource, *ret = NULL; + + mutex_lock(&(sm_state->map_lock)); + @@ -74190,14 +74833,15 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Release a previously acquired resource. -+** The resource will be deleted when its refcount reaches 0. -+*/ -+static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) ++/* ++ * Release a previously acquired resource. ++ * The resource will be deleted when its refcount reaches 0. ++ */ ++static void vmcs_sm_release_resource(struct sm_resource_t *resource, int force) +{ -+ struct SM_PRIV_DATA_T *private = resource->private; ++ struct sm_priv_data_t *private = resource->private; + struct sm_mmap *map, *map_tmp; -+ struct SM_RESOURCE_T *res_tmp; ++ struct sm_resource_t *res_tmp; + int ret; + + mutex_lock(&(sm_state->map_lock)); @@ -74214,7 +74858,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + list_del(&resource->resource_list); + list_del(&resource->global_resource_list); + -+ /* Walk the global resource list, find out if the resource is used ++ /* ++ * Walk the global resource list, find out if the resource is used + * somewhere else. In which case we don't want to delete it. + */ + list_for_each_entry(res_tmp, &sm_state->resource_list, @@ -74248,11 +74893,10 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + up_write(¤t->mm->mmap_sem); + } + -+ /* Free up the videocore allocated resource. -+ */ ++ /* Free up the videocore allocated resource. */ + if (resource->res_handle) { -+ VC_SM_FREE_T free = { -+ resource->res_handle, resource->res_base_mem ++ struct vc_sm_free_t free = { ++ resource->res_handle, (uint32_t)resource->res_base_mem + }; + int status = vc_vchi_sm_free(sm_state->sm_handle, &free, + &private->int_trans_id); @@ -74264,27 +74908,33 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + } + -+ /* Free up the shared resource. -+ */ ++ if (resource->sgt) ++ dma_buf_unmap_attachment(resource->attach, resource->sgt, ++ DMA_BIDIRECTIONAL); ++ if (resource->attach) ++ dma_buf_detach(resource->dma_buf, resource->attach); ++ if (resource->dma_buf) ++ dma_buf_put(resource->dma_buf); ++ ++ /* Free up the shared resource. */ + if (resource->res_shared) + vmcs_sm_release_resource(resource->res_shared, 0); + -+ /* Free up the local resource tracking this allocation. -+ */ ++ /* Free up the local resource tracking this allocation. */ + vc_sm_resource_deceased(resource, force); + kfree(resource); +} + -+/* Dump the map table for the driver. If process is -1, dumps the whole table, -+** if process is a valid pid (non -1) dump only the entries associated with the -+** pid of interest. -+*/ ++/* ++ * Dump the map table for the driver. If process is -1, dumps the whole table, ++ * if process is a valid pid (non -1) dump only the entries associated with the ++ * pid of interest. ++ */ +static void vmcs_sm_host_walk_map_per_pid(int pid) +{ + struct sm_mmap *map = NULL; + -+ /* Make sure the device was started properly. -+ */ ++ /* Make sure the device was started properly. */ + if (sm_state == NULL) { + pr_err("[%s]: invalid device\n", __func__); + return; @@ -74292,8 +74942,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + mutex_lock(&(sm_state->map_lock)); + -+ /* Log all applicable mapping(s). -+ */ ++ /* Log all applicable mapping(s). */ + if (!list_empty(&sm_state->map_list)) { + list_for_each_entry(map, &sm_state->map_list, map_list) { + if (pid == -1 || map->res_pid == pid) { @@ -74305,19 +74954,17 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + + mutex_unlock(&(sm_state->map_lock)); -+ -+ return; +} + -+/* Dump the allocation table from host side point of view. This only dumps the -+** data allocated for this process/device referenced by the file_data. -+*/ -+static void vmcs_sm_host_walk_alloc(struct SM_PRIV_DATA_T *file_data) ++/* ++ * Dump the allocation table from host side point of view. This only dumps the ++ * data allocated for this process/device referenced by the file_data. ++ */ ++static void vmcs_sm_host_walk_alloc(struct sm_priv_data_t *file_data) +{ -+ struct SM_RESOURCE_T *resource = NULL; ++ struct sm_resource_t *resource = NULL; + -+ /* Make sure the device was started properly. -+ */ ++ /* Make sure the device was started properly. */ + if ((sm_state == NULL) || (file_data == NULL)) { + pr_err("[%s]: invalid device\n", __func__); + return; @@ -74336,16 +74983,13 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + + mutex_unlock(&(sm_state->map_lock)); -+ -+ return; +} + -+/* Create support for private data tracking. -+*/ -+static struct SM_PRIV_DATA_T *vc_sm_create_priv_data(pid_t id) ++/* Create support for private data tracking. */ ++static struct sm_priv_data_t *vc_sm_create_priv_data(pid_t id) +{ + char alloc_name[32]; -+ struct SM_PRIV_DATA_T *file_data = NULL; ++ struct sm_priv_data_t *file_data = NULL; + + /* Allocate private structure. */ + file_data = kzalloc(sizeof(*file_data), GFP_KERNEL); @@ -74369,7 +75013,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } else { + struct dentry *dir_entry; + -+ dir_entry = debugfs_create_file(VC_SM_RESOURCES, S_IRUGO, ++ dir_entry = debugfs_create_file(VC_SM_RESOURCES, 0444, + file_data->dir_pid, file_data, + vc_sm_debug_fs_fops); + @@ -74377,7 +75021,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + file_data->dir_res.priv_data = file_data; + file_data->dir_res.show = &vc_sm_alloc_show; + -+ dir_entry = debugfs_create_file(VC_SM_STATS, S_IRUGO, ++ dir_entry = debugfs_create_file(VC_SM_STATS, 0444, + file_data->dir_pid, file_data, + vc_sm_debug_fs_fops); + @@ -74392,15 +75036,15 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return file_data; +} + -+/* Open the device. Creates a private state to help track all allocation -+** associated with this device. -+*/ ++/* ++ * Open the device. Creates a private state to help track all allocation ++ * associated with this device. ++ */ +static int vc_sm_open(struct inode *inode, struct file *file) +{ + int ret = 0; + -+ /* Make sure the device was started properly. -+ */ ++ /* Make sure the device was started properly. */ + if (!sm_state) { + pr_err("[%s]: invalid device\n", __func__); + ret = -EPERM; @@ -74419,18 +75063,18 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Close the device. Free up all resources still associated with this device -+** at the time. -+*/ ++/* ++ * Close the device. Free up all resources still associated with this device ++ * at the time. ++ */ +static int vc_sm_release(struct inode *inode, struct file *file) +{ -+ struct SM_PRIV_DATA_T *file_data = -+ (struct SM_PRIV_DATA_T *)file->private_data; -+ struct SM_RESOURCE_T *resource; ++ struct sm_priv_data_t *file_data = ++ (struct sm_priv_data_t *)file->private_data; ++ struct sm_resource_t *resource; + int ret = 0; + -+ /* Make sure the device was started properly. -+ */ ++ /* Make sure the device was started properly. */ + if (sm_state == NULL || file_data == NULL) { + pr_err("[%s]: invalid device\n", __func__); + ret = -EPERM; @@ -74440,7 +75084,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + pr_debug("[%s]: using private data %p\n", __func__, file_data); + + if (file_data->restart_sys == -EINTR) { -+ VC_SM_ACTION_CLEAN_T action_clean; ++ struct vc_sm_action_clean_t action_clean; + + pr_debug("[%s]: releasing following EINTR on %u (trans_id: %u) (likely due to signal)...\n", + __func__, file_data->int_action, @@ -74460,8 +75104,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + /* Remove the corresponding proc entry. */ + debugfs_remove_recursive(file_data->dir_pid); + -+ /* Terminate the private data. -+ */ ++ /* Terminate the private data. */ + kfree(file_data); + +out: @@ -74489,8 +75132,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + map->ref_count--; + -+ /* Remove from the map table. -+ */ ++ /* Remove from the map table. */ + if (map->ref_count == 0) + vmcs_sm_remove_map(sm_state, map->resource, map); +} @@ -74498,30 +75140,28 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +static int vcsm_vma_fault(struct vm_fault *vmf) +{ + struct sm_mmap *map = (struct sm_mmap *)vmf->vma->vm_private_data; -+ struct SM_RESOURCE_T *resource = map->resource; ++ struct sm_resource_t *resource = map->resource; + pgoff_t page_offset; + unsigned long pfn; + int ret = 0; + -+ /* Lock the resource if necessary. -+ */ ++ /* Lock the resource if necessary. */ + if (!resource->lock_count) { -+ VC_SM_LOCK_UNLOCK_T lock_unlock; -+ VC_SM_LOCK_RESULT_T lock_result; ++ struct vc_sm_lock_unlock_t lock_unlock; ++ struct vc_sm_lock_result_t lock_result; + int status; + + lock_unlock.res_handle = resource->res_handle; -+ lock_unlock.res_mem = resource->res_base_mem; ++ lock_unlock.res_mem = (uint32_t)resource->res_base_mem; + + pr_debug("[%s]: attempt to lock data - hdl %x, base address %p\n", -+ __func__, lock_unlock.res_handle, lock_unlock.res_mem); ++ __func__, lock_unlock.res_handle, ++ (void *)lock_unlock.res_mem); + -+ /* Lock the videocore allocated resource. -+ */ ++ /* Lock the videocore allocated resource. */ + status = vc_vchi_sm_lock(sm_state->sm_handle, + &lock_unlock, &lock_result, 0); -+ if ((status != 0) || -+ ((status == 0) && (lock_result.res_mem == NULL))) { ++ if (status || !lock_result.res_mem) { + pr_err("[%s]: failed to lock memory on videocore (status: %u)\n", + __func__, status); + resource->res_stats[LOCK_FAIL]++; @@ -74535,12 +75175,11 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + resource->res_stats[LOCK]++; + resource->lock_count++; + -+ /* Keep track of the new base memory. -+ */ -+ if ((lock_result.res_mem != NULL) && -+ (lock_result.res_old_mem != NULL) && ++ /* Keep track of the new base memory. */ ++ if (lock_result.res_mem && ++ lock_result.res_old_mem && + (lock_result.res_mem != lock_result.res_old_mem)) { -+ resource->res_base_mem = lock_result.res_mem; ++ resource->res_base_mem = (void *)lock_result.res_mem; + } + } + @@ -74558,9 +75197,9 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + case 0: + case -ERESTARTSYS: + /* -+ * EBUSY is ok: this just means that another thread -+ * already did the job. -+ */ ++ * EBUSY is ok: this just means that another thread ++ * already did the job. ++ */ + case -EBUSY: + return VM_FAULT_NOPAGE; + case -ENOMEM: @@ -74575,7 +75214,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } +} + -+static struct vm_operations_struct vcsm_vm_ops = { ++static const struct vm_operations_struct vcsm_vm_ops = { + .open = vcsm_vma_open, + .close = vcsm_vma_close, + .fault = vcsm_vma_fault, @@ -74638,18 +75277,16 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } while (pgd++, addr = pgd_next, addr != end); +} + -+/* Map an allocated data into something that the user space. -+*/ ++/* Map an allocated data into something that the user space. */ +static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) +{ + int ret = 0; -+ struct SM_PRIV_DATA_T *file_data = -+ (struct SM_PRIV_DATA_T *)file->private_data; -+ struct SM_RESOURCE_T *resource = NULL; ++ struct sm_priv_data_t *file_data = ++ (struct sm_priv_data_t *)file->private_data; ++ struct sm_resource_t *resource = NULL; + struct sm_mmap *map = NULL; + -+ /* Make sure the device was started properly. -+ */ ++ /* Make sure the device was started properly. */ + if ((sm_state == NULL) || (file_data == NULL)) { + pr_err("[%s]: invalid device\n", __func__); + return -EPERM; @@ -74658,11 +75295,12 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + pr_debug("[%s]: private data %p, guid %x\n", __func__, file_data, + ((unsigned int)vma->vm_pgoff << PAGE_SHIFT)); + -+ /* We lookup to make sure that the data we are being asked to mmap is -+ ** something that we allocated. -+ ** -+ ** We use the offset information as the key to tell us which resource -+ ** we are mapping. ++ /* ++ * We lookup to make sure that the data we are being asked to mmap is ++ * something that we allocated. ++ * ++ * We use the offset information as the key to tell us which resource ++ * we are mapping. + */ + resource = vmcs_sm_acquire_resource(file_data, + ((unsigned int)vma->vm_pgoff << @@ -74677,8 +75315,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + __func__, resource->res_guid, current->tgid, resource->pid, + file_data->pid); + -+ /* Check permissions. -+ */ ++ /* Check permissions. */ + if (resource->pid && (resource->pid != current->tgid)) { + pr_err("[%s]: current tgid %u != %u owner\n", + __func__, current->tgid, resource->pid); @@ -74686,8 +75323,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto error; + } + -+ /* Verify that what we are asked to mmap is proper. -+ */ ++ /* Verify that what we are asked to mmap is proper. */ + if (resource->res_size != (unsigned int)(vma->vm_end - vma->vm_start)) { + pr_err("[%s]: size inconsistency (resource: %u - mmap: %u)\n", + __func__, @@ -74698,7 +75334,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto error; + } + -+ /* Keep track of the tuple in the global resource list such that one ++ /* ++ * Keep track of the tuple in the global resource list such that one + * can do a mapping lookup for address/memory handle. + */ + map = kzalloc(sizeof(*map), GFP_KERNEL); @@ -74712,13 +75349,14 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + map->res_pid = current->tgid; + map->res_vc_hdl = resource->res_handle; + map->res_usr_hdl = resource->res_guid; -+ map->res_addr = (long unsigned int)vma->vm_start; ++ map->res_addr = (unsigned long)vma->vm_start; + map->resource = resource; + map->vma = vma; + vmcs_sm_add_map(sm_state, resource, map); + -+ /* We are not actually mapping the pages, we just provide a fault -+ ** handler to allow pages to be mapped when accessed ++ /* ++ * We are not actually mapping the pages, we just provide a fault ++ * handler to allow pages to be mapped when accessed + */ + vma->vm_flags |= + VM_IO | VM_PFNMAP | VM_DONTCOPY | VM_DONTEXPAND; @@ -74732,8 +75370,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + if ((resource->res_cached == VMCS_SM_CACHE_NONE) || + (resource->res_cached == VMCS_SM_CACHE_VC)) { -+ /* Allocated non host cached memory, honour it. -+ */ ++ /* Allocated non host cached memory, honour it. */ + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + } + @@ -74752,6 +75389,22 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + vcsm_vma_open(vma); + resource->res_stats[MAP]++; + vmcs_sm_release_resource(resource, 0); ++ ++ if (resource->map) { ++ /* We don't use vmf->pgoff since that has the fake offset */ ++ unsigned long addr; ++ ++ for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) { ++ /* Finally, remap it */ ++ unsigned long pfn = (unsigned long)resource->res_base_mem & 0x3FFFFFFF; ++ ++ pfn += mm_vc_mem_phys_addr; ++ pfn += addr - vma->vm_start; ++ pfn >>= PAGE_SHIFT; ++ ret = vm_insert_pfn(vma, addr, pfn); ++ } ++ } ++ + return 0; + +error: @@ -74760,20 +75413,27 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Allocate a shared memory handle and block. -+*/ -+int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, ++/* Allocate a shared memory handle and block. */ ++int vc_sm_ioctl_alloc(struct sm_priv_data_t *private, + struct vmcs_sm_ioctl_alloc *ioparam) +{ + int ret = 0; + int status; -+ struct SM_RESOURCE_T *resource; -+ VC_SM_ALLOC_T alloc = { 0 }; -+ VC_SM_ALLOC_RESULT_T result = { 0 }; ++ struct sm_resource_t *resource; ++ struct vc_sm_alloc_t alloc = { 0 }; ++ struct vc_sm_alloc_result_t result = { 0 }; ++ enum vmcs_sm_cache_e cached = ioparam->cached; ++ bool map = false; ++ ++ /* flag to requst buffer is mapped up front, rather than lazily */ ++ if (cached & 0x80) { ++ map = true; ++ cached &= ~0x80; ++ } + + /* Setup our allocation parameters */ -+ alloc.type = ((ioparam->cached == VMCS_SM_CACHE_VC) -+ || (ioparam->cached == ++ alloc.type = ((cached == VMCS_SM_CACHE_VC) ++ || (cached == + VMCS_SM_CACHE_BOTH)) ? VC_SM_ALLOC_CACHED : + VC_SM_ALLOC_NON_CACHED; + alloc.base_unit = ioparam->size; @@ -74795,8 +75455,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + __func__, alloc.name, alloc.type, ioparam->size, + alloc.base_unit, alloc.num_unit, alloc.alignement); + -+ /* Allocate local resource to track this allocation. -+ */ ++ /* Allocate local resource to track this allocation. */ + resource = kzalloc(sizeof(*resource), GFP_KERNEL); + if (!resource) { + ret = -ENOMEM; @@ -74806,8 +75465,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + resource->ref_count++; + resource->pid = current->tgid; + -+ /* Allocate the videocore resource. -+ */ ++ /* Allocate the videocore resource. */ + status = vc_vchi_sm_alloc(sm_state->sm_handle, &alloc, &result, + &private->int_trans_id); + if (status == -EINTR) { @@ -74817,7 +75475,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + private->restart_sys = -EINTR; + private->int_action = VC_SM_MSG_TYPE_ALLOC; + goto error; -+ } else if (status != 0 || (status == 0 && result.res_mem == NULL)) { ++ } else if (status != 0 || !result.res_mem) { + pr_err("[%s]: failed to allocate memory on videocore (status: %u, trans_id: %u)\n", + __func__, status, private->int_trans_id); + ret = -ENOMEM; @@ -74825,15 +75483,16 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto error; + } + -+ /* Keep track of the resource we created. -+ */ ++ /* Keep track of the resource we created. */ + resource->private = private; + resource->res_handle = result.res_handle; -+ resource->res_base_mem = result.res_mem; ++ resource->res_base_mem = (void *)result.res_mem; + resource->res_size = alloc.base_unit * alloc.num_unit; -+ resource->res_cached = ioparam->cached; ++ resource->res_cached = cached; ++ resource->map = map; + -+ /* Kernel/user GUID. This global identifier is used for mmap'ing the ++ /* ++ * Kernel/user GUID. This global identifier is used for mmap'ing the + * allocated region from user space, it is passed as the mmap'ing + * offset, we use it to 'hide' the videocore handle/address. + */ @@ -74865,12 +75524,11 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Share an allocate memory handle and block. -+*/ -+int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, ++/* Share an allocate memory handle and block.*/ ++int vc_sm_ioctl_alloc_share(struct sm_priv_data_t *private, + struct vmcs_sm_ioctl_alloc_share *ioparam) +{ -+ struct SM_RESOURCE_T *resource, *shared_resource; ++ struct sm_resource_t *resource, *shared_resource; + int ret = 0; + + pr_debug("[%s]: attempt to share resource %u\n", __func__, @@ -74882,8 +75540,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto error; + } + -+ /* Allocate local resource to track this allocation. -+ */ ++ /* Allocate local resource to track this allocation. */ + resource = kzalloc(sizeof(*resource), GFP_KERNEL); + if (resource == NULL) { + pr_err("[%s]: failed to allocate local tracking resource\n", @@ -74895,8 +75552,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + resource->ref_count++; + resource->pid = current->tgid; + -+ /* Keep track of the resource we created. -+ */ ++ /* Keep track of the resource we created. */ + resource->private = private; + resource->res_handle = shared_resource->res_handle; + resource->res_base_mem = shared_resource->res_base_mem; @@ -74930,12 +75586,11 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Free a previously allocated shared memory handle and block. -+*/ -+static int vc_sm_ioctl_free(struct SM_PRIV_DATA_T *private, ++/* Free a previously allocated shared memory handle and block.*/ ++static int vc_sm_ioctl_free(struct sm_priv_data_t *private, + struct vmcs_sm_ioctl_free *ioparam) +{ -+ struct SM_RESOURCE_T *resource = ++ struct sm_resource_t *resource = + vmcs_sm_acquire_resource(private, ioparam->handle); + + if (resource == NULL) { @@ -74944,8 +75599,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return -EINVAL; + } + -+ /* Check permissions. -+ */ ++ /* Check permissions. */ + if (resource->pid && (resource->pid != current->tgid)) { + pr_err("[%s]: current tgid %u != %u owner\n", + __func__, current->tgid, resource->pid); @@ -74958,18 +75612,16 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return 0; +} + -+/* Resize a previously allocated shared memory handle and block. -+*/ -+static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, ++/* Resize a previously allocated shared memory handle and block. */ ++static int vc_sm_ioctl_resize(struct sm_priv_data_t *private, + struct vmcs_sm_ioctl_resize *ioparam) +{ + int ret = 0; + int status; -+ VC_SM_RESIZE_T resize; -+ struct SM_RESOURCE_T *resource; ++ struct vc_sm_resize_t resize; ++ struct sm_resource_t *resource; + -+ /* Locate resource from GUID. -+ */ ++ /* Locate resource from GUID. */ + resource = vmcs_sm_acquire_resource(private, ioparam->handle); + if (!resource) { + pr_err("[%s]: failed resource - guid %x\n", @@ -74978,9 +75630,10 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto error; + } + -+ /* If the resource is locked, its reference count will be not NULL, -+ ** in which case we will not be allowed to resize it anyways, so -+ ** reject the attempt here. ++ /* ++ * If the resource is locked, its reference count will be not NULL, ++ * in which case we will not be allowed to resize it anyways, so ++ * reject the attempt here. + */ + if (resource->lock_count != 0) { + pr_err("[%s]: cannot resize - guid %x, ref-cnt %d\n", @@ -74989,8 +75642,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto error; + } + -+ /* Check permissions. -+ */ ++ /* Check permissions. */ + if (resource->pid && (resource->pid != current->tgid)) { + pr_err("[%s]: current tgid %u != %u owner\n", __func__, + current->tgid, resource->pid); @@ -75006,14 +75658,14 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + + resize.res_handle = resource->res_handle; -+ resize.res_mem = resource->res_base_mem; ++ resize.res_mem = (uint32_t)resource->res_base_mem; + resize.res_new_size = ioparam->new_size; + + pr_debug("[%s]: attempt to resize data - guid %x, hdl %x, base address %p\n", -+ __func__, ioparam->handle, resize.res_handle, resize.res_mem); ++ __func__, ioparam->handle, resize.res_handle, ++ (void *)resize.res_mem); + -+ /* Resize the videocore allocated resource. -+ */ ++ /* Resize the videocore allocated resource. */ + status = vc_vchi_sm_resize(sm_state->sm_handle, &resize, + &private->int_trans_id); + if (status == -EINTR) { @@ -75023,7 +75675,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + private->restart_sys = -EINTR; + private->int_action = VC_SM_MSG_TYPE_RESIZE; + goto error; -+ } else if (status != 0) { ++ } else if (status) { + pr_err("[%s]: failed to resize memory on videocore (status: %u, trans_id: %u)\n", + __func__, status, private->int_trans_id); + ret = -EPERM; @@ -75034,8 +75686,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + __func__, resize.res_handle, resource->res_size, + resize.res_new_size); + -+ /* Successfully resized, save the information and inform the user. -+ */ ++ /* Successfully resized, save the information and inform the user. */ + ioparam->old_size = resource->res_size; + resource->res_size = resize.res_new_size; + @@ -75046,33 +75697,30 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Lock a previously allocated shared memory handle and block. -+*/ -+static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, ++/* Lock a previously allocated shared memory handle and block. */ ++static int vc_sm_ioctl_lock(struct sm_priv_data_t *private, + struct vmcs_sm_ioctl_lock_unlock *ioparam, + int change_cache, enum vmcs_sm_cache_e cache_type, + unsigned int vc_addr) +{ + int status; -+ VC_SM_LOCK_UNLOCK_T lock; -+ VC_SM_LOCK_RESULT_T result; -+ struct SM_RESOURCE_T *resource; ++ struct vc_sm_lock_unlock_t lock; ++ struct vc_sm_lock_result_t result; ++ struct sm_resource_t *resource; + int ret = 0; + struct sm_mmap *map, *map_tmp; -+ long unsigned int phys_addr; ++ unsigned long phys_addr; + + map = NULL; + -+ /* Locate resource from GUID. -+ */ ++ /* Locate resource from GUID. */ + resource = vmcs_sm_acquire_resource(private, ioparam->handle); + if (resource == NULL) { + ret = -EINVAL; + goto error; + } + -+ /* Check permissions. -+ */ ++ /* Check permissions. */ + if (resource->pid && (resource->pid != current->tgid)) { + pr_err("[%s]: current tgid %u != %u owner\n", __func__, + current->tgid, resource->pid); @@ -75081,17 +75729,15 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + + lock.res_handle = resource->res_handle; -+ lock.res_mem = resource->res_base_mem; ++ lock.res_mem = (uint32_t)resource->res_base_mem; + -+ /* Take the lock and get the address to be mapped. -+ */ ++ /* Take the lock and get the address to be mapped. */ + if (vc_addr == 0) { + pr_debug("[%s]: attempt to lock data - guid %x, hdl %x, base address %p\n", + __func__, ioparam->handle, lock.res_handle, -+ lock.res_mem); ++ (void *)lock.res_mem); + -+ /* Lock the videocore allocated resource. -+ */ ++ /* Lock the videocore allocated resource. */ + status = vc_vchi_sm_lock(sm_state->sm_handle, &lock, &result, + &private->int_trans_id); + if (status == -EINTR) { @@ -75101,8 +75747,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + private->restart_sys = -EINTR; + private->int_action = VC_SM_MSG_TYPE_LOCK; + goto error; -+ } else if (status != 0 || -+ (status == 0 && result.res_mem == NULL)) { ++ } else if (status || ++ (!status && !(void *)result.res_mem)) { + pr_err("[%s]: failed to lock memory on videocore (status: %u, trans_id: %u)\n", + __func__, status, private->int_trans_id); + ret = -EPERM; @@ -75111,27 +75757,24 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + + pr_debug("[%s]: succeed to lock data - hdl %x, base address %p (%p), ref-cnt %d\n", -+ __func__, lock.res_handle, result.res_mem, -+ lock.res_mem, resource->lock_count); ++ __func__, lock.res_handle, (void *)result.res_mem, ++ (void *)lock.res_mem, resource->lock_count); + } -+ /* Lock assumed taken already, address to be mapped is known. -+ */ ++ /* Lock assumed taken already, address to be mapped is known. */ + else + resource->res_base_mem = (void *)vc_addr; + + resource->res_stats[LOCK]++; + resource->lock_count++; + -+ /* Keep track of the new base memory allocation if it has changed. -+ */ ++ /* Keep track of the new base memory allocation if it has changed. */ + if ((vc_addr == 0) && -+ (result.res_mem != NULL) && -+ (result.res_old_mem != NULL) && ++ ((void *)result.res_mem) && ++ ((void *)result.res_old_mem) && + (result.res_mem != result.res_old_mem)) { -+ resource->res_base_mem = result.res_mem; ++ resource->res_base_mem = (void *)result.res_mem; + -+ /* Kernel allocated resources. -+ */ ++ /* Kernel allocated resources. */ + if (resource->pid == 0) { + if (!list_empty(&resource->map_list)) { + list_for_each_entry_safe(map, map_tmp, @@ -75163,8 +75806,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + __func__, resource->map_count, private->pid, + current->tgid, ioparam->handle, ioparam->addr); + } else { -+ /* Kernel allocated resources. -+ */ ++ /* Kernel allocated resources. */ + if (resource->pid == 0) { + pr_debug("[%s]: attempt mapping kernel resource - guid %x, hdl %x\n", + __func__, ioparam->handle, lock.res_handle); @@ -75183,7 +75825,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + phys_addr += mm_vc_mem_phys_addr; + if (resource->res_cached + == VMCS_SM_CACHE_HOST) { -+ ioparam->addr = (long unsigned int) ++ ioparam->addr = (unsigned long) + /* TODO - make cached work */ + ioremap_nocache(phys_addr, + resource->res_size); @@ -75192,7 +75834,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + __func__, ioparam->handle, + lock.res_handle, ioparam->addr); + } else { -+ ioparam->addr = (long unsigned int) ++ ioparam->addr = (unsigned long) + ioremap_nocache(phys_addr, + resource->res_size); + @@ -75221,30 +75863,27 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Unlock a previously allocated shared memory handle and block. -+*/ -+static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, ++/* Unlock a previously allocated shared memory handle and block.*/ ++static int vc_sm_ioctl_unlock(struct sm_priv_data_t *private, + struct vmcs_sm_ioctl_lock_unlock *ioparam, + int flush, int wait_reply, int no_vc_unlock) +{ + int status; -+ VC_SM_LOCK_UNLOCK_T unlock; ++ struct vc_sm_lock_unlock_t unlock; + struct sm_mmap *map, *map_tmp; -+ struct SM_RESOURCE_T *resource; ++ struct sm_resource_t *resource; + int ret = 0; + + map = NULL; + -+ /* Locate resource from GUID. -+ */ ++ /* Locate resource from GUID. */ + resource = vmcs_sm_acquire_resource(private, ioparam->handle); + if (resource == NULL) { + ret = -EINVAL; + goto error; + } + -+ /* Check permissions. -+ */ ++ /* Check permissions. */ + if (resource->pid && (resource->pid != current->tgid)) { + pr_err("[%s]: current tgid %u != %u owner\n", + __func__, current->tgid, resource->pid); @@ -75253,17 +75892,18 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + + unlock.res_handle = resource->res_handle; -+ unlock.res_mem = resource->res_base_mem; ++ unlock.res_mem = (uint32_t)resource->res_base_mem; + + pr_debug("[%s]: attempt to unlock data - guid %x, hdl %x, base address %p\n", -+ __func__, ioparam->handle, unlock.res_handle, unlock.res_mem); ++ __func__, ioparam->handle, unlock.res_handle, ++ (void *)unlock.res_mem); + -+ /* User space allocated resources. -+ */ ++ /* User space allocated resources. */ + if (resource->pid) { + /* Flush if requested */ + if (resource->res_cached && flush) { + dma_addr_t phys_addr = 0; ++ + resource->res_stats[FLUSH]++; + + phys_addr = @@ -75278,6 +75918,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + if (map->vma) { + unsigned long start; + unsigned long end; ++ + start = map->vma->vm_start; + end = map->vma->vm_end; + @@ -75320,7 +75961,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + if (flush && + (resource->res_cached == + VMCS_SM_CACHE_HOST)) { -+ long unsigned int ++ unsigned long + phys_addr; + phys_addr = (uint32_t) + resource->res_base_mem & 0x3FFFFFFF; @@ -75356,12 +75997,10 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + + if (resource->lock_count) { -+ /* Bypass the videocore unlock. -+ */ ++ /* Bypass the videocore unlock. */ + if (no_vc_unlock) + status = 0; -+ /* Unlock the videocore allocated resource. -+ */ ++ /* Unlock the videocore allocated resource. */ + else { + status = + vc_vchi_sm_unlock(sm_state->sm_handle, &unlock, @@ -75391,7 +76030,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + + pr_debug("[%s]: success to unlock data - hdl %x, base address %p, ref-cnt %d\n", -+ __func__, unlock.res_handle, unlock.res_mem, ++ __func__, unlock.res_handle, (void *)unlock.res_mem, + resource->lock_count); + +error: @@ -75401,14 +76040,143 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + ++/* Import a contiguous block of memory to be shared with VC. */ ++int vc_sm_ioctl_import_dmabuf(struct sm_priv_data_t *private, ++ struct vmcs_sm_ioctl_import_dmabuf *ioparam, ++ struct dma_buf *src_dma_buf) ++{ ++ int ret = 0; ++ int status; ++ struct sm_resource_t *resource = NULL; ++ struct vc_sm_import import = { 0 }; ++ struct vc_sm_import_result result = { 0 }; ++ struct dma_buf *dma_buf; ++ struct dma_buf_attachment *attach = NULL; ++ struct sg_table *sgt = NULL; ++ ++ /* Setup our allocation parameters */ ++ if (src_dma_buf) { ++ get_dma_buf(src_dma_buf); ++ dma_buf = src_dma_buf; ++ } else { ++ dma_buf = dma_buf_get(ioparam->dmabuf_fd); ++ } ++ if (IS_ERR(dma_buf)) ++ return PTR_ERR(dma_buf); ++ ++ attach = dma_buf_attach(dma_buf, &sm_state->pdev->dev); ++ if (IS_ERR(attach)) { ++ ret = PTR_ERR(attach); ++ goto error; ++ } ++ ++ sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL); ++ if (IS_ERR(sgt)) { ++ ret = PTR_ERR(sgt); ++ goto error; ++ } ++ ++ /* Verify that the address block is contiguous */ ++ if (sgt->nents != 1) { ++ ret = -ENOMEM; ++ goto error; ++ } ++ ++ import.type = ((ioparam->cached == VMCS_SM_CACHE_VC) || ++ (ioparam->cached == VMCS_SM_CACHE_BOTH)) ? ++ VC_SM_ALLOC_CACHED : VC_SM_ALLOC_NON_CACHED; ++ import.addr = (uint32_t)sg_dma_address(sgt->sgl); ++ import.size = sg_dma_len(sgt->sgl); ++ import.allocator = current->tgid; ++ ++ if (*ioparam->name) ++ memcpy(import.name, ioparam->name, sizeof(import.name) - 1); ++ else ++ memcpy(import.name, VMCS_SM_RESOURCE_NAME_DEFAULT, ++ sizeof(VMCS_SM_RESOURCE_NAME_DEFAULT)); ++ ++ pr_debug("[%s]: attempt to import \"%s\" data - type %u, addr %p, size %u\n", ++ __func__, import.name, import.type, ++ (void *)import.addr, import.size); ++ ++ /* Allocate local resource to track this allocation. */ ++ resource = kzalloc(sizeof(*resource), GFP_KERNEL); ++ if (!resource) { ++ ret = -ENOMEM; ++ goto error; ++ } ++ INIT_LIST_HEAD(&resource->map_list); ++ resource->ref_count++; ++ resource->pid = current->tgid; ++ ++ /* Allocate the videocore resource. */ ++ status = vc_vchi_sm_import(sm_state->sm_handle, &import, &result, ++ &private->int_trans_id); ++ if (status == -EINTR) { ++ pr_debug("[%s]: requesting import memory action restart (trans_id: %u)\n", ++ __func__, private->int_trans_id); ++ ret = -ERESTARTSYS; ++ private->restart_sys = -EINTR; ++ private->int_action = VC_SM_MSG_TYPE_IMPORT; ++ goto error; ++ } else if (status || !result.res_handle) { ++ pr_debug("[%s]: failed to import memory on videocore (status: %u, trans_id: %u)\n", ++ __func__, status, private->int_trans_id); ++ ret = -ENOMEM; ++ resource->res_stats[ALLOC_FAIL]++; ++ goto error; ++ } ++ ++ /* Keep track of the resource we created. */ ++ resource->private = private; ++ resource->res_handle = result.res_handle; ++ resource->res_size = import.size; ++ resource->res_cached = ioparam->cached; ++ ++ resource->dma_buf = dma_buf; ++ resource->attach = attach; ++ resource->sgt = sgt; ++ resource->dma_addr = sg_dma_address(sgt->sgl); ++ ++ /* ++ * Kernel/user GUID. This global identifier is used for mmap'ing the ++ * allocated region from user space, it is passed as the mmap'ing ++ * offset, we use it to 'hide' the videocore handle/address. ++ */ ++ mutex_lock(&sm_state->lock); ++ resource->res_guid = ++sm_state->guid; ++ mutex_unlock(&sm_state->lock); ++ resource->res_guid <<= PAGE_SHIFT; ++ ++ vmcs_sm_add_resource(private, resource); ++ ++ /* We're done */ ++ resource->res_stats[IMPORT]++; ++ ioparam->handle = resource->res_guid; ++ return 0; ++ ++error: ++ resource->res_stats[IMPORT_FAIL]++; ++ if (resource) { ++ vc_sm_resource_deceased(resource, 1); ++ kfree(resource); ++ } ++ if (sgt) ++ dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL); ++ if (attach) ++ dma_buf_detach(dma_buf, attach); ++ dma_buf_put(dma_buf); ++ return ret; ++} ++ +/* Handle control from host. */ +static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + int ret = 0; + unsigned int cmdnr = _IOC_NR(cmd); -+ struct SM_PRIV_DATA_T *file_data = -+ (struct SM_PRIV_DATA_T *)file->private_data; -+ struct SM_RESOURCE_T *resource = NULL; ++ struct sm_priv_data_t *file_data = ++ (struct sm_priv_data_t *)file->private_data; ++ struct sm_resource_t *resource = NULL; + + /* Validate we can work with this device. */ + if ((sm_state == NULL) || (file_data == NULL)) { @@ -75422,7 +76190,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + /* Action is a re-post of a previously interrupted action? */ + if (file_data->restart_sys == -EINTR) { -+ VC_SM_ACTION_CLEAN_T action_clean; ++ struct vc_sm_action_clean_t action_clean; + + pr_debug("[%s]: clean up of action %u (trans_id: %u) following EINTR\n", + __func__, file_data->int_action, @@ -75436,8 +76204,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + file_data->restart_sys = 0; + } + -+ /* Now process the command. -+ */ ++ /* Now process the command. */ + switch (cmdnr) { + /* New memory allocation. + */ @@ -75445,8 +76212,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + { + struct vmcs_sm_ioctl_alloc ioparam; + -+ /* Get the parameter data. -+ */ ++ /* Get the parameter data. */ + if (copy_from_user + (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { + pr_err("[%s]: failed to copy-from-user for cmd %x\n", @@ -75468,20 +76234,17 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + ret = -EFAULT; + } + -+ /* Done. -+ */ ++ /* Done. */ + goto out; + } + break; + -+ /* Share existing memory allocation. -+ */ ++ /* Share existing memory allocation. */ + case VMCS_SM_CMD_ALLOC_SHARE: + { + struct vmcs_sm_ioctl_alloc_share ioparam; + -+ /* Get the parameter data. -+ */ ++ /* Get the parameter data. */ + if (copy_from_user + (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { + pr_err("[%s]: failed to copy-from-user for cmd %x\n", @@ -75492,8 +76255,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + ret = vc_sm_ioctl_alloc_share(file_data, &ioparam); + -+ /* Copy result back to user. -+ */ ++ /* Copy result back to user. */ + if (!ret + && copy_to_user((void *)arg, &ioparam, + sizeof(ioparam)) != 0) { @@ -75506,21 +76268,50 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + ret = -EFAULT; + } + -+ /* Done. -+ */ ++ /* Done. */ + goto out; + } + break; + -+ /* Lock (attempt to) *and* register a cache behavior change. -+ */ ++ case VMCS_SM_CMD_IMPORT_DMABUF: ++ { ++ struct vmcs_sm_ioctl_import_dmabuf ioparam; ++ ++ /* Get the parameter data. */ ++ if (copy_from_user ++ (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { ++ pr_err("[%s]: failed to copy-from-user for cmd %x\n", ++ __func__, cmdnr); ++ ret = -EFAULT; ++ goto out; ++ } ++ ++ ret = vc_sm_ioctl_import_dmabuf(file_data, &ioparam, ++ NULL); ++ if (!ret && ++ (copy_to_user((void *)arg, ++ &ioparam, sizeof(ioparam)) != 0)) { ++ struct vmcs_sm_ioctl_free freeparam = { ++ ioparam.handle ++ }; ++ pr_err("[%s]: failed to copy-to-user for cmd %x\n", ++ __func__, cmdnr); ++ vc_sm_ioctl_free(file_data, &freeparam); ++ ret = -EFAULT; ++ } ++ ++ /* Done. */ ++ goto out; ++ } ++ break; ++ ++ /* Lock (attempt to) *and* register a cache behavior change. */ + case VMCS_SM_CMD_LOCK_CACHE: + { + struct vmcs_sm_ioctl_lock_cache ioparam; + struct vmcs_sm_ioctl_lock_unlock lock; + -+ /* Get parameter data. -+ */ ++ /* Get parameter data. */ + if (copy_from_user + (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { + pr_err("[%s]: failed to copy-from-user for cmd %x\n", @@ -75534,20 +76325,17 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + vc_sm_ioctl_lock(file_data, &lock, 1, + ioparam.cached, 0); + -+ /* Done. -+ */ ++ /* Done. */ + goto out; + } + break; + -+ /* Lock (attempt to) existing memory allocation. -+ */ ++ /* Lock (attempt to) existing memory allocation. */ + case VMCS_SM_CMD_LOCK: + { + struct vmcs_sm_ioctl_lock_unlock ioparam; + -+ /* Get parameter data. -+ */ ++ /* Get parameter data. */ + if (copy_from_user + (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { + pr_err("[%s]: failed to copy-from-user for cmd %x\n", @@ -75558,8 +76346,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + ret = vc_sm_ioctl_lock(file_data, &ioparam, 0, 0, 0); + -+ /* Copy result back to user. -+ */ ++ /* Copy result back to user. */ + if (copy_to_user((void *)arg, &ioparam, sizeof(ioparam)) + != 0) { + pr_err("[%s]: failed to copy-to-user for cmd %x\n", @@ -75567,20 +76354,17 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + ret = -EFAULT; + } + -+ /* Done. -+ */ ++ /* Done. */ + goto out; + } + break; + -+ /* Unlock (attempt to) existing memory allocation. -+ */ ++ /* Unlock (attempt to) existing memory allocation. */ + case VMCS_SM_CMD_UNLOCK: + { + struct vmcs_sm_ioctl_lock_unlock ioparam; + -+ /* Get parameter data. -+ */ ++ /* Get parameter data. */ + if (copy_from_user + (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { + pr_err("[%s]: failed to copy-from-user for cmd %x\n", @@ -75591,20 +76375,17 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + ret = vc_sm_ioctl_unlock(file_data, &ioparam, 0, 1, 0); + -+ /* Done. -+ */ ++ /* Done. */ + goto out; + } + break; + -+ /* Resize (attempt to) existing memory allocation. -+ */ ++ /* Resize (attempt to) existing memory allocation. */ + case VMCS_SM_CMD_RESIZE: + { + struct vmcs_sm_ioctl_resize ioparam; + -+ /* Get parameter data. -+ */ ++ /* Get parameter data. */ + if (copy_from_user + (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { + pr_err("[%s]: failed to copy-from-user for cmd %x\n", @@ -75615,17 +76396,13 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + ret = vc_sm_ioctl_resize(file_data, &ioparam); + -+ /* Copy result back to user. -+ */ ++ /* Copy result back to user. */ + if (copy_to_user((void *)arg, &ioparam, sizeof(ioparam)) + != 0) { + pr_err("[%s]: failed to copy-to-user for cmd %x\n", + __func__, cmdnr); + ret = -EFAULT; + } -+ -+ /* Done. -+ */ + goto out; + } + break; @@ -75670,7 +76447,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto out; + } + break; -+/* Walk mapping table on host, information shows up in the ++ /* Walk mapping table on host, information shows up in the + ** kernel log. + */ + case VMCS_SM_CMD_HOST_WALK_MAP: @@ -75709,7 +76486,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + { + struct vmcs_sm_ioctl_walk ioparam; + -+ /* Get parameter data. */ ++ /* Get parameter data. */ + if (copy_from_user(&ioparam, + (void *)arg, sizeof(ioparam)) != 0) { + pr_err("[%s]: failed to copy-from-user for cmd %x\n", @@ -75766,8 +76543,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + { + struct vmcs_sm_ioctl_chk ioparam; + -+ /* Get parameter data. -+ */ ++ /* Get parameter data. */ + if (copy_from_user(&ioparam, + (void *)arg, sizeof(ioparam)) != 0) { + pr_err("[%s]: failed to copy-from-user for cmd %x\n", @@ -75782,7 +76558,8 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + vmcs_sm_acquire_resource(file_data, ioparam.handle); + if (resource == NULL) + ret = -EINVAL; -+ /* If the resource is cacheable, return additional ++ /* ++ * If the resource is cacheable, return additional + * information that may be needed to flush the cache. + */ + else if ((resource->res_cached == VMCS_SM_CACHE_HOST) || @@ -75808,8 +76585,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + ret = -EFAULT; + } + -+ /* Done. -+ */ ++ /* Done. */ + goto out; + } + break; @@ -75888,8 +76664,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + ret = -EFAULT; + } + -+ /* Done. -+ */ ++ /* Done. */ + goto out; + } + break; @@ -75971,8 +76746,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + } + break; + -+ /* Maps a user address given process and vc handle. -+ */ ++ /* Maps a user address given process and vc handle. */ + case VMCS_SM_CMD_MAPPED_USR_ADDRESS: + { + struct vmcs_sm_ioctl_map ioparam; @@ -76075,8 +76849,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto out; + } + -+ /* Locate resource from GUID. -+ */ ++ /* Locate resource from GUID. */ + resource = + vmcs_sm_acquire_resource(file_data, ioparam.handle); + @@ -76112,8 +76885,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + if (resource) + vmcs_sm_release_resource(resource, 0); + -+ /* Done. -+ */ ++ /* Done. */ + goto out; + } + break; @@ -76132,40 +76904,92 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + ret = -EFAULT; + goto out; + } -+ for (i=0; ires_cached) { -+ unsigned long base = ioparam.s[i].addr & ~(PAGE_SIZE-1); -+ unsigned long end = (ioparam.s[i].addr + ioparam.s[i].size + PAGE_SIZE-1) & ~(PAGE_SIZE-1); -+ resource->res_stats[ioparam.s[i].cmd == 1 ? INVALID:FLUSH]++; ++ if ((resource != NULL) && resource->res_cached) { ++ unsigned long base = ioparam.s[i].addr & ~(PAGE_SIZE - 1); ++ unsigned long end = (ioparam.s[i].addr + ioparam.s[i].size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); + -+ /* L1/L2 cache flush */ -+ down_read(¤t->mm->mmap_sem); -+ vcsm_vma_cache_clean_page_range(base, end); -+ up_read(¤t->mm->mmap_sem); -+ } else if (resource == NULL) { -+ ret = -EINVAL; -+ goto out; -+ } ++ resource->res_stats[ioparam.s[i].cmd == 1 ? INVALID : FLUSH]++; + -+ if (resource) -+ vmcs_sm_release_resource(resource, 0); ++ /* L1/L2 cache flush */ ++ down_read(¤t->mm->mmap_sem); ++ vcsm_vma_cache_clean_page_range(base, end); ++ up_read(¤t->mm->mmap_sem); ++ } else if (resource == NULL) { ++ ret = -EINVAL; ++ goto out; + } ++ ++ if (resource) ++ vmcs_sm_release_resource(resource, 0); ++ + break; + } + } + } + break; ++ /* Flush/Invalidate the cache for a given mapping. */ ++ case VMCS_SM_CMD_CLEAN_INVALID2: ++ { ++ int i, j; ++ struct vmcs_sm_ioctl_clean_invalid2 ioparam; ++ struct vmcs_sm_ioctl_clean_invalid_block *block = NULL; ++ ++ /* Get parameter data. */ ++ if (copy_from_user(&ioparam, ++ (void *)arg, sizeof(ioparam)) != 0) { ++ pr_err("[%s]: failed to copy-from-user header for cmd %x\n", ++ __func__, cmdnr); ++ ret = -EFAULT; ++ goto out; ++ } ++ block = kmalloc(ioparam.op_count * ++ sizeof(struct vmcs_sm_ioctl_clean_invalid_block), ++ GFP_KERNEL); ++ if (!block) { ++ ret = -EFAULT; ++ goto out; ++ } ++ if (copy_from_user(block, ++ (void *)(arg + sizeof(ioparam)), ioparam.op_count * sizeof(struct vmcs_sm_ioctl_clean_invalid_block)) != 0) { ++ pr_err("[%s]: failed to copy-from-user payload for cmd %x\n", ++ __func__, cmdnr); ++ ret = -EFAULT; ++ goto out; ++ } ++ ++ for (i = 0; i < ioparam.op_count; i++) { ++ const struct vmcs_sm_ioctl_clean_invalid_block * const op = block + i; ++ cache_flush_op_fn * const op_fn = flushops[op->invalidate_mode & 3]; ++ ++ if ((op->invalidate_mode & ~3) != 0) { ++ ret = -EINVAL; ++ break; ++ } ++ ++ if (op_fn == 0) ++ continue; ++ ++ for (j = 0; j < op->block_count; ++j) { ++ const char * const base = (const char *)op->start_address + j * op->inter_block_stride; ++ const char * const end = base + op->block_size; ++ op_fn(base, end); ++ } ++ } ++ kfree(block); ++ } ++ break; + + default: + { @@ -76179,8 +77003,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Device operations that we managed in this driver. -+*/ ++/* Device operations that we managed in this driver. */ +static const struct file_operations vmcs_sm_ops = { + .owner = THIS_MODULE, + .unlocked_ioctl = vc_sm_ioctl, @@ -76189,8 +77012,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + .mmap = vc_sm_mmap, +}; + -+/* Creation of device. -+*/ ++/* Creation of device. */ +static int vc_sm_create_sharedmemory(void) +{ + int ret; @@ -76200,8 +77022,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto out; + } + -+ /* Create a device class for creating dev nodes. -+ */ ++ /* Create a device class for creating dev nodes. */ + sm_state->sm_class = class_create(THIS_MODULE, "vc-sm"); + if (IS_ERR(sm_state->sm_class)) { + pr_err("[%s]: unable to create device class\n", __func__); @@ -76209,8 +77030,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto out; + } + -+ /* Create a character driver. -+ */ ++ /* Create a character driver. */ + ret = alloc_chrdev_region(&sm_state->sm_devid, + DEVICE_MINOR, 1, DEVICE_NAME); + if (ret != 0) { @@ -76225,8 +77045,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto out_chrdev_unreg; + } + -+ /* Create a device node. -+ */ ++ /* Create a device node. */ + sm_state->sm_dev = device_create(sm_state->sm_class, + NULL, + MKDEV(MAJOR(sm_state->sm_devid), @@ -76251,25 +77070,21 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} + -+/* Termination of the device. -+*/ ++/* Termination of the device. */ +static int vc_sm_remove_sharedmemory(void) +{ + int ret; + + if (sm_state == NULL) { -+ /* Nothing to do. -+ */ ++ /* Nothing to do. */ + ret = 0; + goto out; + } + -+ /* Remove the sharedmemory character driver. -+ */ ++ /* Remove the sharedmemory character driver. */ + cdev_del(&sm_state->sm_cdev); + -+ /* Unregister region. -+ */ ++ /* Unregister region. */ + unregister_chrdev_region(sm_state->sm_devid, 1); + + ret = 0; @@ -76288,20 +77103,9 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + pr_info("[%s]: start\n", __func__); + -+ /* Allocate memory for the state structure. -+ */ -+ sm_state = kzalloc(sizeof(struct SM_STATE_T), GFP_KERNEL); -+ if (sm_state == NULL) { -+ pr_err("[%s]: failed to allocate memory\n", __func__); -+ ret = -ENOMEM; -+ goto out; -+ } -+ -+ mutex_init(&sm_state->lock); -+ mutex_init(&sm_state->map_lock); -+ -+ /* Initialize and create a VCHI connection for the shared memory service -+ ** running on videocore. ++ /* ++ * Initialize and create a VCHI connection for the shared memory service ++ * running on videocore. + */ + ret = vchi_initialise(&vchi_instance); + if (ret != 0) { @@ -76344,12 +77148,12 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + + sm_state->dir_state.show = &vc_sm_global_state_show; + sm_state->dir_state.dir_entry = debugfs_create_file(VC_SM_STATE, -+ S_IRUGO, sm_state->dir_root, &sm_state->dir_state, ++ 0444, sm_state->dir_root, &sm_state->dir_state, + &vc_sm_debug_fs_fops); + + sm_state->dir_stats.show = &vc_sm_global_statistics_show; + sm_state->dir_stats.dir_entry = debugfs_create_file(VC_SM_STATS, -+ S_IRUGO, sm_state->dir_root, &sm_state->dir_stats, ++ 0444, sm_state->dir_root, &sm_state->dir_stats, + &vc_sm_debug_fs_fops); + + /* Create the proc entry children. */ @@ -76374,8 +77178,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + goto err_remove_shared_memory; + } + -+ /* Done! -+ */ ++ /* Done! */ + sm_inited = 1; + goto out; + @@ -76392,49 +77195,53 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} + +/* Driver loading. */ -+static int __init vc_sm_init(void) ++static int bcm2835_vcsm_probe(struct platform_device *pdev) +{ + pr_info("vc-sm: Videocore shared memory driver\n"); ++ ++ sm_state = kzalloc(sizeof(*sm_state), GFP_KERNEL); ++ if (!sm_state) ++ return -ENOMEM; ++ sm_state->pdev = pdev; ++ mutex_init(&sm_state->lock); ++ mutex_init(&sm_state->map_lock); ++ + vchiq_add_connected_callback(vc_sm_connected_init); + return 0; +} + +/* Driver unloading. */ -+static void __exit vc_sm_exit(void) ++static int bcm2835_vcsm_remove(struct platform_device *pdev) +{ + pr_debug("[%s]: start\n", __func__); + if (sm_inited) { -+ /* Remove shared memory device. -+ */ ++ /* Remove shared memory device. */ + vc_sm_remove_sharedmemory(); + -+ /* Remove all proc entries. -+ */ ++ /* Remove all proc entries. */ + debugfs_remove_recursive(sm_state->dir_root); + -+ /* Stop the videocore shared memory service. -+ */ ++ /* Stop the videocore shared memory service. */ + vc_vchi_sm_stop(&sm_state->sm_handle); + -+ /* Free the memory for the state structure. -+ */ ++ /* Free the memory for the state structure. */ + mutex_destroy(&(sm_state->map_lock)); + kfree(sm_state); + } + + pr_debug("[%s]: end\n", __func__); ++ return 0; +} + +#if defined(__KERNEL__) +/* Allocate a shared memory handle and block. */ -+int vc_sm_alloc(VC_SM_ALLOC_T *alloc, int *handle) ++int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle) +{ + struct vmcs_sm_ioctl_alloc ioparam = { 0 }; + int ret; -+ struct SM_RESOURCE_T *resource; ++ struct sm_resource_t *resource; + -+ /* Validate we can work with this device. -+ */ ++ /* Validate we can work with this device. */ + if (sm_state == NULL || alloc == NULL || handle == NULL) { + pr_err("[%s]: invalid input\n", __func__); + return -EPERM; @@ -76455,8 +77262,7 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + resource->pid = 0; + vmcs_sm_release_resource(resource, 0); + -+ /* Assign valid handle at this time. -+ */ ++ /* Assign valid handle at this time. */ + *handle = ioparam.handle; + } else { + ret = -ENOMEM; @@ -76467,22 +77273,19 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} +EXPORT_SYMBOL_GPL(vc_sm_alloc); + -+/* Get an internal resource handle mapped from the external one. -+*/ ++/* Get an internal resource handle mapped from the external one. */ +int vc_sm_int_handle(int handle) +{ -+ struct SM_RESOURCE_T *resource; ++ struct sm_resource_t *resource; + int ret = 0; + -+ /* Validate we can work with this device. -+ */ ++ /* Validate we can work with this device. */ + if (sm_state == NULL || handle == 0) { + pr_err("[%s]: invalid input\n", __func__); + return 0; + } + -+ /* Locate resource from GUID. -+ */ ++ /* Locate resource from GUID. */ + resource = vmcs_sm_acquire_resource(sm_state->data_knl, handle); + if (resource) { + ret = resource->res_handle; @@ -76493,14 +77296,12 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} +EXPORT_SYMBOL_GPL(vc_sm_int_handle); + -+/* Free a previously allocated shared memory handle and block. -+*/ ++/* Free a previously allocated shared memory handle and block. */ +int vc_sm_free(int handle) +{ + struct vmcs_sm_ioctl_free ioparam = { handle }; + -+ /* Validate we can work with this device. -+ */ ++ /* Validate we can work with this device. */ + if (sm_state == NULL || handle == 0) { + pr_err("[%s]: invalid input\n", __func__); + return -EPERM; @@ -76510,16 +77311,14 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} +EXPORT_SYMBOL_GPL(vc_sm_free); + -+/* Lock a memory handle for use by kernel. -+*/ -+int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, -+ long unsigned int *data) ++/* Lock a memory handle for use by kernel. */ ++int vc_sm_lock(int handle, enum vc_sm_lock_cache_mode mode, ++ unsigned long *data) +{ + struct vmcs_sm_ioctl_lock_unlock ioparam; + int ret; + -+ /* Validate we can work with this device. -+ */ ++ /* Validate we can work with this device. */ + if (sm_state == NULL || handle == 0 || data == NULL) { + pr_err("[%s]: invalid input\n", __func__); + return -EPERM; @@ -76540,14 +77339,12 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} +EXPORT_SYMBOL_GPL(vc_sm_lock); + -+/* Unlock a memory handle in use by kernel. -+*/ ++/* Unlock a memory handle in use by kernel. */ +int vc_sm_unlock(int handle, int flush, int no_vc_unlock) +{ + struct vmcs_sm_ioctl_lock_unlock ioparam; + -+ /* Validate we can work with this device. -+ */ ++ /* Validate we can work with this device. */ + if (sm_state == NULL || handle == 0) { + pr_err("[%s]: invalid input\n", __func__); + return -EPERM; @@ -76559,16 +77356,14 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 +} +EXPORT_SYMBOL_GPL(vc_sm_unlock); + -+/* Map a shared memory region for use by kernel. -+*/ -+int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, -+ long unsigned int *data) ++/* Map a shared memory region for use by kernel. */ ++int vc_sm_map(int handle, unsigned int sm_addr, ++ enum vc_sm_lock_cache_mode mode, unsigned long *data) +{ + struct vmcs_sm_ioctl_lock_unlock ioparam; + int ret; + -+ /* Validate we can work with this device. -+ */ ++ /* Validate we can work with this device. */ + if (sm_state == NULL || handle == 0 || data == NULL || sm_addr == 0) { + pr_err("[%s]: invalid input\n", __func__); + return -EPERM; @@ -76588,20 +77383,76 @@ index 0000000000000000000000000000000000000000..fd2ca788dcd56b1702454d71b7bedd42 + return ret; +} +EXPORT_SYMBOL_GPL(vc_sm_map); ++ ++/* Import a dmabuf to be shared with VC. */ ++int vc_sm_import_dmabuf(struct dma_buf *dmabuf, int *handle) ++{ ++ struct vmcs_sm_ioctl_import_dmabuf ioparam = { 0 }; ++ int ret; ++ struct sm_resource_t *resource; ++ ++ /* Validate we can work with this device. */ ++ if (!sm_state || !dmabuf || !handle) { ++ pr_err("[%s]: invalid input\n", __func__); ++ return -EPERM; ++ } ++ ++ ioparam.cached = 0; ++ strcpy(ioparam.name, "KRNL DMABUF"); ++ ++ ret = vc_sm_ioctl_import_dmabuf(sm_state->data_knl, &ioparam, dmabuf); ++ ++ if (!ret) { ++ resource = vmcs_sm_acquire_resource(sm_state->data_knl, ++ ioparam.handle); ++ if (resource) { ++ resource->pid = 0; ++ vmcs_sm_release_resource(resource, 0); ++ ++ /* Assign valid handle at this time.*/ ++ *handle = ioparam.handle; ++ } else { ++ ret = -ENOMEM; ++ } ++ } ++ ++ return ret; ++} ++EXPORT_SYMBOL_GPL(vc_sm_import_dmabuf); +#endif + -+late_initcall(vc_sm_init); -+module_exit(vc_sm_exit); ++/* ++ * Register the driver with device tree ++ */ ++ ++static const struct of_device_id bcm2835_vcsm_of_match[] = { ++ {.compatible = "raspberrypi,bcm2835-vcsm",}, ++ { /* sentinel */ }, ++}; ++ ++MODULE_DEVICE_TABLE(of, bcm2835_vcsm_of_match); ++ ++static struct platform_driver bcm2835_vcsm_driver = { ++ .probe = bcm2835_vcsm_probe, ++ .remove = bcm2835_vcsm_remove, ++ .driver = { ++ .name = DRIVER_NAME, ++ .owner = THIS_MODULE, ++ .of_match_table = bcm2835_vcsm_of_match, ++ }, ++}; ++ ++module_platform_driver(bcm2835_vcsm_driver); + +MODULE_AUTHOR("Broadcom"); +MODULE_DESCRIPTION("VideoCore SharedMemory Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/broadcom/vmcs_sm_ioctl.h b/include/linux/broadcom/vmcs_sm_ioctl.h new file mode 100644 -index 0000000000000000000000000000000000000000..334f36d0d697b047df2922b5f2db67f38cf76564 +index 0000000000000000000000000000000000000000..b75729d762f25aace133f7a008633b4094ae2de2 --- /dev/null +++ b/include/linux/broadcom/vmcs_sm_ioctl.h -@@ -0,0 +1,248 @@ +@@ -0,0 +1,280 @@ +/***************************************************************************** +* Copyright 2011 Broadcom Corporation. All rights reserved. +* @@ -76666,8 +77517,11 @@ index 0000000000000000000000000000000000000000..334f36d0d697b047df2922b5f2db67f3 + VMCS_SM_CMD_HOST_WALK_PID_MAP, + + VMCS_SM_CMD_CLEAN_INVALID, ++ VMCS_SM_CMD_CLEAN_INVALID2, + -+ VMCS_SM_CMD_LAST /* Do no delete */ ++ VMCS_SM_CMD_IMPORT_DMABUF, ++ ++ VMCS_SM_CMD_LAST /* Do not delete */ +}; + +/* Cache type supported, conveniently matches the user space definition in @@ -76779,6 +77633,28 @@ index 0000000000000000000000000000000000000000..334f36d0d697b047df2922b5f2db67f3 + } s[8]; +}; + ++struct vmcs_sm_ioctl_clean_invalid2 { ++ uint8_t op_count; ++ uint8_t zero[3]; ++ struct vmcs_sm_ioctl_clean_invalid_block { ++ uint16_t invalidate_mode; ++ uint16_t block_count; ++ void * start_address; ++ uint32_t block_size; ++ uint32_t inter_block_stride; ++ } s[0]; ++}; ++ ++struct vmcs_sm_ioctl_import_dmabuf { ++ /* user -> kernel */ ++ int dmabuf_fd; ++ enum vmcs_sm_cache_e cached; ++ char name[VMCS_SM_RESOURCE_NAME]; ++ ++ /* kernel -> user */ ++ unsigned int handle; ++}; ++ +/* IOCTL numbers */ +#define VMCS_SM_IOCTL_MEM_ALLOC\ + _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_ALLOC,\ @@ -76810,6 +77686,9 @@ index 0000000000000000000000000000000000000000..334f36d0d697b047df2922b5f2db67f3 +#define VMCS_SM_IOCTL_MEM_CLEAN_INVALID\ + _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_CLEAN_INVALID,\ + struct vmcs_sm_ioctl_clean_invalid) ++#define VMCS_SM_IOCTL_MEM_CLEAN_INVALID2\ ++ _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_CLEAN_INVALID2,\ ++ struct vmcs_sm_ioctl_clean_invalid2) + +#define VMCS_SM_IOCTL_SIZE_USR_HDL\ + _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_SIZE_USR_HANDLE,\ @@ -76845,16 +77724,20 @@ index 0000000000000000000000000000000000000000..334f36d0d697b047df2922b5f2db67f3 + _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_HOST_WALK_PID_MAP,\ + struct vmcs_sm_ioctl_walk) + ++#define VMCS_SM_IOCTL_MEM_IMPORT_DMABUF\ ++ _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_IMPORT_DMABUF,\ ++ struct vmcs_sm_ioctl_import_dmabuf) ++ +/* ---- Variable Externs ------------------------------------------------- */ + +/* ---- Function Prototypes ---------------------------------------------- */ + +#endif /* __VMCS_SM_IOCTL_H__INCLUDED__ */ -From 54dbad72f925213c1d1dbb49b7f3beb4cd6f903d Mon Sep 17 00:00:00 2001 +From 3799b1cc77322f1925aa87ca58b77989ca5a689e Mon Sep 17 00:00:00 2001 From: Luke Wren Date: Fri, 21 Aug 2015 23:14:48 +0100 -Subject: [PATCH 042/199] Add /dev/gpiomem device for rootless user GPIO access +Subject: [PATCH 047/129] Add /dev/gpiomem device for rootless user GPIO access Signed-off-by: Luke Wren @@ -77162,10 +78045,10 @@ index 0000000000000000000000000000000000000000..f5e7f1ba8fb6f18dee77fad06a17480c +MODULE_DESCRIPTION("gpiomem driver for accessing GPIO from userspace"); +MODULE_AUTHOR("Luke Wren "); -From d3452b6add04eb41f7e5a09e4f01564b60097792 Mon Sep 17 00:00:00 2001 +From 6cb24300772167b1c4bb07a7985d025cb508380a Mon Sep 17 00:00:00 2001 From: Luke Wren Date: Sat, 5 Sep 2015 01:14:45 +0100 -Subject: [PATCH 043/199] Add SMI driver +Subject: [PATCH 048/129] Add SMI driver Signed-off-by: Luke Wren --- @@ -79116,10 +79999,10 @@ index 0000000000000000000000000000000000000000..ee3a75edfc033eeb0d90a687ffb68b10 + +#endif /* BCM2835_SMI_H */ -From c8104c25a060cf241303b97395eddc0fb3ea147f Mon Sep 17 00:00:00 2001 +From aeb4c4d9a548d638db0b305484e0b764fa20d82d Mon Sep 17 00:00:00 2001 From: Martin Sperl Date: Tue, 26 Apr 2016 14:59:21 +0000 -Subject: [PATCH 044/199] MISC: bcm2835: smi: use clock manager and fix reload +Subject: [PATCH 049/129] MISC: bcm2835: smi: use clock manager and fix reload issues Use clock manager instead of self-made clockmanager. @@ -79289,10 +80172,10 @@ index 63a4ea08b9930a3a31a985f0a1d969b488ed49ec..1261540703127d1d63b9f3c87042c6e5 return 0; } -From d4f1a556543c7c328259d77dcd0b5714117aba16 Mon Sep 17 00:00:00 2001 +From 0597e8bf3e75f13e7cfdc469efe8abe23d01d2b1 Mon Sep 17 00:00:00 2001 From: Luke Wren Date: Sat, 5 Sep 2015 01:16:10 +0100 -Subject: [PATCH 045/199] Add SMI NAND driver +Subject: [PATCH 050/129] Add SMI NAND driver Signed-off-by: Luke Wren --- @@ -79657,10 +80540,10 @@ index 0000000000000000000000000000000000000000..02adda6da18bd0ba9ab19a104975b79d + ("Driver for NAND chips using Broadcom Secondary Memory Interface"); +MODULE_AUTHOR("Luke Wren "); -From 0a89639705fca9304c067c288364b9997c4b37a7 Mon Sep 17 00:00:00 2001 +From 1053b28a97453d1b844f569a035e7a9024087ebe Mon Sep 17 00:00:00 2001 From: Aron Szabo Date: Sat, 16 Jun 2012 12:15:55 +0200 -Subject: [PATCH 046/199] lirc: added support for RaspberryPi GPIO +Subject: [PATCH 051/129] lirc: added support for RaspberryPi GPIO lirc_rpi: Use read_current_timer to determine transmitter delay. Thanks to jjmz and others See: https://github.com/raspberrypi/linux/issues/525 @@ -80520,17 +81403,22 @@ index 0000000000000000000000000000000000000000..fb69624ccef00ddbdccf8256d6baf1b1 + +#endif -From 53134e4c000e21874d0a50c3d416b3728a3a621a Mon Sep 17 00:00:00 2001 +From f1a2739582a18d8e0694b78191dc6226473e94e5 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Wed, 3 Jul 2013 00:49:20 +0100 -Subject: [PATCH 047/199] Add cpufreq driver +Subject: [PATCH 052/129] Add cpufreq driver Signed-off-by: popcornmix + +bcm2835-cpufreq: Change licence to GPLv2 + +Signed-off-by: Eben Upton +Signed-off-by: Dom Cobley --- drivers/cpufreq/Kconfig.arm | 9 ++ drivers/cpufreq/Makefile | 1 + - drivers/cpufreq/bcm2835-cpufreq.c | 218 ++++++++++++++++++++++++++++++++++++++ - 3 files changed, 228 insertions(+) + drivers/cpufreq/bcm2835-cpufreq.c | 210 ++++++++++++++++++++++++++++++++++++++ + 3 files changed, 220 insertions(+) create mode 100644 drivers/cpufreq/bcm2835-cpufreq.c diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm @@ -80567,32 +81455,24 @@ index ab3a42cd29ef210bcf0cad2ee48c74cb954b14f2..f81761612a9bef474090a868305bb86e obj-$(CONFIG_ARM_TEGRA186_CPUFREQ) += tegra186-cpufreq.o diff --git a/drivers/cpufreq/bcm2835-cpufreq.c b/drivers/cpufreq/bcm2835-cpufreq.c new file mode 100644 -index 0000000000000000000000000000000000000000..414fbdc10dfbfc6e4bb47870a7af3fd5780f9c9a +index 0000000000000000000000000000000000000000..99345969b0e4d651fd9033d67de2febb13fc0892 --- /dev/null +++ b/drivers/cpufreq/bcm2835-cpufreq.c -@@ -0,0 +1,218 @@ -+/***************************************************************************** -+* Copyright 2011 Broadcom Corporation. All rights reserved. -+* -+* Unless you and Broadcom execute a separate written software license -+* agreement governing use of this software, this software is licensed to you -+* under the terms of the GNU General Public License version 2, available at -+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+* -+* Notwithstanding the above, under no circumstances may you combine this -+* software in any way with any other Broadcom software provided under a -+* license other than the GPL, without Broadcom's express prior written -+* consent. -+*****************************************************************************/ -+ -+/***************************************************************************** -+* FILENAME: bcm2835-cpufreq.h -+* DESCRIPTION: This driver dynamically manages the CPU Frequency of the ARM -+* processor. Messages are sent to Videocore either setting or requesting the -+* frequency of the ARM in order to match an appropiate frequency to the current -+* usage of the processor. The policy which selects the frequency to use is -+* defined in the kernel .config file, but can be changed during runtime. -+*****************************************************************************/ +@@ -0,0 +1,210 @@ ++/* ++ * Copyright 2011 Broadcom Corporation. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; version 2 ++ * of the License. ++ * ++ * This driver dynamically manages the CPU Frequency of the ARM ++ * processor. Messages are sent to Videocore either setting or requesting the ++ * frequency of the ARM in order to match an appropiate frequency to the current ++ * usage of the processor. The policy which selects the frequency to use is ++ * defined in the kernel .config file, but can be changed during runtime. ++ */ + +/* ---------- INCLUDES ---------- */ +#include @@ -80790,10 +81670,10 @@ index 0000000000000000000000000000000000000000..414fbdc10dfbfc6e4bb47870a7af3fd5 +module_init(bcm2835_cpufreq_module_init); +module_exit(bcm2835_cpufreq_module_exit); -From 5efe200e855b813f52f9b651554e077af87dec1f Mon Sep 17 00:00:00 2001 +From bdcf2fea9d9494b1bde5be20708639a899caabc4 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Wed, 17 Jun 2015 15:44:08 +0100 -Subject: [PATCH 048/199] Add Chris Boot's i2c driver +Subject: [PATCH 053/129] Add Chris Boot's i2c driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -81458,10 +82338,10 @@ index 0000000000000000000000000000000000000000..962f2e5c7455d91bf32925d785f5f16b +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); -From d1a193f2ba50338e517f3fa9e8f1f25401f764a0 Mon Sep 17 00:00:00 2001 +From b3412fd2008d4fc5ef921840c534e637a6acc44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Fri, 26 Jun 2015 14:27:06 +0200 -Subject: [PATCH 049/199] char: broadcom: Add vcio module +Subject: [PATCH 054/129] char: broadcom: Add vcio module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -81686,10 +82566,10 @@ index 0000000000000000000000000000000000000000..c19bc2075c77879563ef5e59038b5a14 +MODULE_DESCRIPTION("Mailbox userspace access"); +MODULE_LICENSE("GPL"); -From a2a6e93609a97bc827d97d746a0678f50f12fcf9 Mon Sep 17 00:00:00 2001 +From 904187645d8f723be83183d949edd5f4934b2962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Fri, 26 Jun 2015 14:25:01 +0200 -Subject: [PATCH 050/199] firmware: bcm2835: Support ARCH_BCM270x +Subject: [PATCH 055/129] firmware: bcm2835: Support ARCH_BCM270x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -81772,10 +82652,10 @@ index dd506cd3a5b874f9e1acd07efb8cd151bb6145d1..3f070bd38a91511c986e3fb114b15bd4 MODULE_AUTHOR("Eric Anholt "); MODULE_DESCRIPTION("Raspberry Pi firmware driver"); -From ac7a24adc1031d34e81e8d3116f92cd6fd47d978 Mon Sep 17 00:00:00 2001 +From be3055df75011cc2027acab5bf2f294e0543e02f Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 11 May 2015 09:00:42 +0100 -Subject: [PATCH 051/199] scripts: Add mkknlimg and knlinfo scripts from tools +Subject: [PATCH 056/129] scripts: Add mkknlimg and knlinfo scripts from tools repo The Raspberry Pi firmware looks for a trailer on the kernel image to @@ -82302,10 +83182,10 @@ index 0000000000000000000000000000000000000000..84be2593ec1de8f97b0167ff06b3e05d + return $trailer; +} -From 9f3ce085aca3f7c192c9dcd61a19bff71a9c728a Mon Sep 17 00:00:00 2001 +From c063b1ed6fac8ef79ccb0c14ef662515e93787f5 Mon Sep 17 00:00:00 2001 From: notro Date: Wed, 9 Jul 2014 14:46:08 +0200 -Subject: [PATCH 052/199] BCM2708: Add core Device Tree support +Subject: [PATCH 057/129] BCM2708: Add core Device Tree support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -82505,12 +83385,12 @@ Signed-off-by: Phil Elwell arch/arm/Makefile | 2 + arch/arm/boot/.gitignore | 2 +- arch/arm/boot/dts/Makefile | 20 + - arch/arm/boot/dts/bcm2708-rpi-0-w.dts | 162 +++ + arch/arm/boot/dts/bcm2708-rpi-0-w.dts | 162 ++ arch/arm/boot/dts/bcm2708-rpi-b-plus.dts | 122 ++ arch/arm/boot/dts/bcm2708-rpi-b.dts | 112 ++ arch/arm/boot/dts/bcm2708-rpi-cm.dts | 95 ++ arch/arm/boot/dts/bcm2708-rpi-cm.dtsi | 17 + - arch/arm/boot/dts/bcm2708-rpi.dtsi | 174 +++ + arch/arm/boot/dts/bcm2708-rpi.dtsi | 162 ++ arch/arm/boot/dts/bcm2708.dtsi | 20 + arch/arm/boot/dts/bcm2709-rpi-2-b.dts | 122 ++ arch/arm/boot/dts/bcm2709.dtsi | 22 + @@ -82519,8 +83399,8 @@ Signed-off-by: Phil Elwell arch/arm/boot/dts/bcm2710-rpi-cm3.dts | 129 ++ arch/arm/boot/dts/bcm2710.dtsi | 148 ++ arch/arm/boot/dts/bcm283x.dtsi | 13 +- - arch/arm/boot/dts/overlays/Makefile | 118 ++ - arch/arm/boot/dts/overlays/README | 1517 ++++++++++++++++++++ + arch/arm/boot/dts/overlays/Makefile | 125 ++ + arch/arm/boot/dts/overlays/README | 1620 ++++++++++++++++++++ .../arm/boot/dts/overlays/adau1977-adc-overlay.dts | 40 + .../boot/dts/overlays/adau7002-simple-overlay.dts | 52 + arch/arm/boot/dts/overlays/ads1015-overlay.dts | 98 ++ @@ -82528,6 +83408,7 @@ Signed-off-by: Phil Elwell arch/arm/boot/dts/overlays/ads7846-overlay.dts | 89 ++ .../dts/overlays/akkordion-iqdacplus-overlay.dts | 49 + .../allo-boss-dac-pcm512x-audio-overlay.dts | 59 + + .../arm/boot/dts/overlays/allo-digione-overlay.dts | 44 + .../allo-piano-dac-pcm512x-audio-overlay.dts | 54 + .../allo-piano-dac-plus-pcm512x-audio-overlay.dts | 55 + arch/arm/boot/dts/overlays/at86rf233-overlay.dts | 57 + @@ -82545,9 +83426,11 @@ Signed-off-by: Phil Elwell arch/arm/boot/dts/overlays/enc28j60-overlay.dts | 53 + .../boot/dts/overlays/enc28j60-spi2-overlay.dts | 47 + arch/arm/boot/dts/overlays/fe-pi-audio-overlay.dts | 70 + + arch/arm/boot/dts/overlays/goodix-overlay.dts | 46 + .../overlays/googlevoicehat-soundcard-overlay.dts | 49 + arch/arm/boot/dts/overlays/gpio-ir-overlay.dts | 44 + .../boot/dts/overlays/gpio-poweroff-overlay.dts | 34 + + .../boot/dts/overlays/gpio-shutdown-overlay.dts | 80 + .../boot/dts/overlays/hifiberry-amp-overlay.dts | 39 + .../boot/dts/overlays/hifiberry-dac-overlay.dts | 34 + .../dts/overlays/hifiberry-dacplus-overlay.dts | 59 + @@ -82559,10 +83442,11 @@ Signed-off-by: Phil Elwell arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts | 43 + arch/arm/boot/dts/overlays/i2c-mux-overlay.dts | 139 ++ .../boot/dts/overlays/i2c-pwm-pca9685a-overlay.dts | 26 + - arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts | 83 ++ - arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts | 49 + + .../arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts | 183 +++ + arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts | 164 ++ + arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts | 142 ++ .../arm/boot/dts/overlays/i2c0-bcm2708-overlay.dts | 61 + - .../arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts | 37 + + .../arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts | 34 + .../boot/dts/overlays/i2s-gpio28-31-overlay.dts | 18 + arch/arm/boot/dts/overlays/iqaudio-dac-overlay.dts | 46 + .../boot/dts/overlays/iqaudio-dacplus-overlay.dts | 49 + @@ -82571,12 +83455,14 @@ Signed-off-by: Phil Elwell .../boot/dts/overlays/justboom-digi-overlay.dts | 41 + arch/arm/boot/dts/overlays/lirc-rpi-overlay.dts | 57 + arch/arm/boot/dts/overlays/mcp23017-overlay.dts | 54 + - arch/arm/boot/dts/overlays/mcp23s17-overlay.dts | 732 ++++++++++ + arch/arm/boot/dts/overlays/mcp23s17-overlay.dts | 732 +++++++++ .../arm/boot/dts/overlays/mcp2515-can0-overlay.dts | 73 + .../arm/boot/dts/overlays/mcp2515-can1-overlay.dts | 73 + arch/arm/boot/dts/overlays/mcp3008-overlay.dts | 205 +++ arch/arm/boot/dts/overlays/midi-uart0-overlay.dts | 36 + + arch/arm/boot/dts/overlays/midi-uart1-overlay.dts | 43 + arch/arm/boot/dts/overlays/mmc-overlay.dts | 39 + + arch/arm/boot/dts/overlays/mpu6050-overlay.dts | 28 + arch/arm/boot/dts/overlays/mz61581-overlay.dts | 117 ++ arch/arm/boot/dts/overlays/pi3-act-led-overlay.dts | 27 + .../boot/dts/overlays/pi3-disable-bt-overlay.dts | 46 + @@ -82594,6 +83480,7 @@ Signed-off-by: Phil Elwell arch/arm/boot/dts/overlays/pwm-overlay.dts | 43 + arch/arm/boot/dts/overlays/qca7000-overlay.dts | 52 + arch/arm/boot/dts/overlays/raspidac3-overlay.dts | 49 + + .../boot/dts/overlays/rotary-encoder-overlay.dts | 43 + .../boot/dts/overlays/rpi-backlight-overlay.dts | 21 + .../dts/overlays/rpi-cirrus-wm5102-overlay.dts | 146 ++ arch/arm/boot/dts/overlays/rpi-dac-overlay.dts | 34 + @@ -82618,10 +83505,10 @@ Signed-off-by: Phil Elwell arch/arm/boot/dts/overlays/spi0-hw-cs-overlay.dts | 26 + arch/arm/boot/dts/overlays/spi1-1cs-overlay.dts | 57 + arch/arm/boot/dts/overlays/spi1-2cs-overlay.dts | 69 + - arch/arm/boot/dts/overlays/spi1-3cs-overlay.dts | 81 ++ + arch/arm/boot/dts/overlays/spi1-3cs-overlay.dts | 81 + arch/arm/boot/dts/overlays/spi2-1cs-overlay.dts | 57 + arch/arm/boot/dts/overlays/spi2-2cs-overlay.dts | 69 + - arch/arm/boot/dts/overlays/spi2-3cs-overlay.dts | 81 ++ + arch/arm/boot/dts/overlays/spi2-3cs-overlay.dts | 81 + arch/arm/boot/dts/overlays/tinylcd35-overlay.dts | 224 +++ arch/arm/boot/dts/overlays/uart1-overlay.dts | 38 + .../arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts | 89 ++ @@ -82632,7 +83519,7 @@ Signed-off-by: Phil Elwell arch/arm/boot/dts/overlays/wittypi-overlay.dts | 44 + scripts/Makefile.dtbinst | 8 +- scripts/Makefile.lib | 11 + - 130 files changed, 10133 insertions(+), 6 deletions(-) + 137 files changed, 10869 insertions(+), 6 deletions(-) create mode 100644 arch/arm/boot/dts/bcm2708-rpi-0-w.dts create mode 100644 arch/arm/boot/dts/bcm2708-rpi-b-plus.dts create mode 100644 arch/arm/boot/dts/bcm2708-rpi-b.dts @@ -82655,6 +83542,7 @@ Signed-off-by: Phil Elwell create mode 100644 arch/arm/boot/dts/overlays/ads7846-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/akkordion-iqdacplus-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/allo-boss-dac-pcm512x-audio-overlay.dts + create mode 100644 arch/arm/boot/dts/overlays/allo-digione-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/allo-piano-dac-pcm512x-audio-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/allo-piano-dac-plus-pcm512x-audio-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/at86rf233-overlay.dts @@ -82672,9 +83560,11 @@ Signed-off-by: Phil Elwell create mode 100644 arch/arm/boot/dts/overlays/enc28j60-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/enc28j60-spi2-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/fe-pi-audio-overlay.dts + create mode 100644 arch/arm/boot/dts/overlays/goodix-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/googlevoicehat-soundcard-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/gpio-ir-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/gpio-poweroff-overlay.dts + create mode 100644 arch/arm/boot/dts/overlays/gpio-shutdown-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/hifiberry-amp-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/hifiberry-dac-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/hifiberry-dacplus-overlay.dts @@ -82686,6 +83576,7 @@ Signed-off-by: Phil Elwell create mode 100644 arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/i2c-mux-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/i2c-pwm-pca9685a-overlay.dts + create mode 100644 arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/i2c0-bcm2708-overlay.dts @@ -82703,7 +83594,9 @@ Signed-off-by: Phil Elwell create mode 100644 arch/arm/boot/dts/overlays/mcp2515-can1-overlay.dts create mode 100755 arch/arm/boot/dts/overlays/mcp3008-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/midi-uart0-overlay.dts + create mode 100644 arch/arm/boot/dts/overlays/midi-uart1-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/mmc-overlay.dts + create mode 100644 arch/arm/boot/dts/overlays/mpu6050-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/mz61581-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/pi3-act-led-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/pi3-disable-bt-overlay.dts @@ -82721,6 +83614,7 @@ Signed-off-by: Phil Elwell create mode 100644 arch/arm/boot/dts/overlays/pwm-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/qca7000-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/raspidac3-overlay.dts + create mode 100644 arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/rpi-backlight-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/rpi-cirrus-wm5102-overlay.dts create mode 100644 arch/arm/boot/dts/overlays/rpi-dac-overlay.dts @@ -83362,10 +84256,10 @@ index 0000000000000000000000000000000000000000..d0299e3d9a09ddcdad80cb0957b30b14 +}; diff --git a/arch/arm/boot/dts/bcm2708-rpi.dtsi b/arch/arm/boot/dts/bcm2708-rpi.dtsi new file mode 100644 -index 0000000000000000000000000000000000000000..29dde110e769082a24640d3c7284afb8e99b226c +index 0000000000000000000000000000000000000000..f88b844f0aff82742966fd820f6f69cf25c2dfab --- /dev/null +++ b/arch/arm/boot/dts/bcm2708-rpi.dtsi -@@ -0,0 +1,174 @@ +@@ -0,0 +1,162 @@ +/* Downstream version of bcm2835-rpi.dtsi */ + +#include @@ -83442,6 +84336,12 @@ index 0000000000000000000000000000000000000000..29dde110e769082a24640d3c7284afb8 + firmware = <&firmware>; + }; + ++ vcsm: vcsm { ++ compatible = "raspberrypi,bcm2835-vcsm"; ++ firmware = <&firmware>; ++ status = "okay"; ++ }; ++ + thermal: thermal@7e212000 { + #thermal-sensor-cells = <0>; + status = "okay"; @@ -83458,30 +84358,6 @@ index 0000000000000000000000000000000000000000..29dde110e769082a24640d3c7284afb8 + sound: sound { + status = "disabled"; + }; -+ -+ thermal-zones { -+ cpu_thermal: cpu-thermal { -+ polling-delay-passive = <0>; -+ polling-delay = <1000>; -+ -+ thermal-sensors = <&thermal>; -+ -+ /* No trips -+ trips { -+ cpu-crit { -+ temperature = <80000>; -+ hysteresis = <0>; -+ type = "critical"; -+ }; -+ }; -+ */ -+ -+ coefficients = <(-538) 407000>; -+ -+ cooling-maps { -+ }; -+ }; -+ }; + }; + + __overrides__ { @@ -83540,6 +84416,12 @@ index 0000000000000000000000000000000000000000..29dde110e769082a24640d3c7284afb8 +&fb { + status = "okay"; +}; ++ ++&cpu_thermal { ++ coefficients = <(-538) 407000>; ++ ++ /delete-node/ trips; ++}; diff --git a/arch/arm/boot/dts/bcm2708.dtsi b/arch/arm/boot/dts/bcm2708.dtsi new file mode 100644 index 0000000000000000000000000000000000000000..756bd3687b488da98f749b27ddfe098693990045 @@ -84411,10 +85293,10 @@ index 431dcfc900c024d85a88231d1df007916dafdfeb..6a119d30c5f8c2d13deacea646af8c30 #size-cells = <0>; diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile new file mode 100644 -index 0000000000000000000000000000000000000000..e2f66a55dc5afe13d690c2c17827054ac94b7168 +index 0000000000000000000000000000000000000000..c50b1dfa9d7334df47ce087f9d2a7a816afa05ba --- /dev/null +++ b/arch/arm/boot/dts/overlays/Makefile -@@ -0,0 +1,118 @@ +@@ -0,0 +1,125 @@ +# Overlays for the Raspberry Pi platform + +dtbo-$(CONFIG_ARCH_BCM2835) += \ @@ -84425,6 +85307,7 @@ index 0000000000000000000000000000000000000000..e2f66a55dc5afe13d690c2c17827054a + ads7846.dtbo \ + akkordion-iqdacplus.dtbo \ + allo-boss-dac-pcm512x-audio.dtbo \ ++ allo-digione.dtbo \ + allo-piano-dac-pcm512x-audio.dtbo \ + allo-piano-dac-plus-pcm512x-audio.dtbo \ + at86rf233.dtbo \ @@ -84442,9 +85325,11 @@ index 0000000000000000000000000000000000000000..e2f66a55dc5afe13d690c2c17827054a + enc28j60.dtbo \ + enc28j60-spi2.dtbo \ + fe-pi-audio.dtbo \ ++ goodix.dtbo \ + googlevoicehat-soundcard.dtbo \ + gpio-ir.dtbo \ + gpio-poweroff.dtbo \ ++ gpio-shutdown.dtbo \ + hifiberry-amp.dtbo \ + hifiberry-dac.dtbo \ + hifiberry-dacplus.dtbo \ @@ -84457,6 +85342,7 @@ index 0000000000000000000000000000000000000000..e2f66a55dc5afe13d690c2c17827054a + i2c-mux.dtbo \ + i2c-pwm-pca9685a.dtbo \ + i2c-rtc.dtbo \ ++ i2c-rtc-gpio.dtbo \ + i2c-sensor.dtbo \ + i2c0-bcm2708.dtbo \ + i2c1-bcm2708.dtbo \ @@ -84473,7 +85359,9 @@ index 0000000000000000000000000000000000000000..e2f66a55dc5afe13d690c2c17827054a + mcp2515-can1.dtbo \ + mcp3008.dtbo \ + midi-uart0.dtbo \ ++ midi-uart1.dtbo \ + mmc.dtbo \ ++ mpu6050.dtbo \ + mz61581.dtbo \ + pi3-act-led.dtbo \ + pi3-disable-bt.dtbo \ @@ -84491,6 +85379,7 @@ index 0000000000000000000000000000000000000000..e2f66a55dc5afe13d690c2c17827054a + pwm-2chan.dtbo \ + qca7000.dtbo \ + raspidac3.dtbo \ ++ rotary-encoder.dtbo \ + rpi-backlight.dtbo \ + rpi-cirrus-wm5102.dtbo \ + rpi-dac.dtbo \ @@ -84535,10 +85424,10 @@ index 0000000000000000000000000000000000000000..e2f66a55dc5afe13d690c2c17827054a +clean-files := *.dtbo diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README new file mode 100644 -index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b2b54e53b +index 0000000000000000000000000000000000000000..e6d777a601c91d192bc5713f9a73e1a2d4d708ef --- /dev/null +++ b/arch/arm/boot/dts/overlays/README -@@ -0,0 +1,1517 @@ +@@ -0,0 +1,1620 @@ +Introduction +============ + @@ -84828,6 +85717,12 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b + slave" + + ++Name: allo-digione ++Info: Configures the Allo Digione audio card ++Load: dtoverlay=allo-digione ++Params: ++ ++ +Name: allo-piano-dac-pcm512x-audio +Info: Configures the Allo Piano DAC (2.0/2.1) audio cards. + (NB. This initial support is for 2.0 channel audio ONLY! ie. stereo. @@ -85000,6 +85895,14 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b +Params: + + ++Name: goodix ++Info: Enables I2C connected Goodix gt9271 multiple touch controller using ++ GPIOs 4 and 17 (pins 7 and 11 on GPIO header) for interrupt and reset. ++Load: dtoverlay=goodix,= ++Params: interrupt GPIO used for interrupt (default 4) ++ reset GPIO used for reset (default 17) ++ ++ +Name: googlevoicehat-soundcard +Info: Configures the Google voiceHAT soundcard +Load: dtoverlay=googlevoicehat-soundcard @@ -85035,6 +85938,38 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b + will also cause the pin to go low. + + ++Name: gpio-shutdown ++Info: Initiates a shutdown when GPIO pin changes. The given GPIO pin ++ is configured as an input key that generates KEY_POWER events. ++ This event is handled by systemd-logind by initiating a ++ shutdown. Systemd versions older than 225 need an udev rule ++ enable listening to the input device: ++ ++ ACTION!="REMOVE", SUBSYSTEM=="input", KERNEL=="event*", \ ++ SUBSYSTEMS=="platform", DRIVERS=="gpio-keys", \ ++ ATTRS{keys}=="116", TAG+="power-switch" ++ ++ This overlay only handles shutdown. After shutdown, the system ++ can be powered up again by driving GPIO3 low. The default ++ configuration uses GPIO3 with a pullup, so if you connect a ++ button between GPIO3 and GND (pin 5 and 6 on the 40-pin header), ++ you get a shutdown and power-up button. ++Load: dtoverlay=gpio-shutdown,= ++Params: gpio_pin GPIO pin to trigger on (default 3) ++ ++ active_low When this is 1 (active low), a falling ++ edge generates a key down event and a ++ rising edge generates a key up event. ++ When this is 0 (active high), this is ++ reversed. The default is 1 (active low). ++ ++ gpio_pull Desired pull-up/down state (off, down, up) ++ Default is "up". ++ ++ Note that the default pin (GPIO3) has an ++ external pullup. ++ ++ +Name: hifiberry-amp +Info: Configures the HifiBerry Amp and Amp+ audio cards +Load: dtoverlay=hifiberry-amp @@ -85189,22 +86124,77 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b + source + + ++Name: i2c-rtc-gpio ++Info: Adds support for a number of I2C Real Time Clock devices ++ using the software i2c controller ++Load: dtoverlay=i2c-rtc-gpio,= ++Params: abx80x Select one of the ABx80x family: ++ AB0801, AB0803, AB0804, AB0805, ++ AB1801, AB1803, AB1804, AB1805 ++ ++ ds1307 Select the DS1307 device ++ ++ ds1339 Select the DS1339 device ++ ++ ds3231 Select the DS3231 device ++ ++ mcp7940x Select the MCP7940x device ++ ++ mcp7941x Select the MCP7941x device ++ ++ pcf2127 Select the PCF2127 device ++ ++ pcf8523 Select the PCF8523 device ++ ++ pcf8563 Select the PCF8563 device ++ ++ trickle-diode-type Diode type for trickle charge - "standard" or ++ "schottky" (ABx80x only) ++ ++ trickle-resistor-ohms Resistor value for trickle charge (DS1339, ++ ABx80x) ++ ++ wakeup-source Specify that the RTC can be used as a wakeup ++ source ++ ++ i2c_gpio_sda GPIO used for I2C data (default "23") ++ ++ i2c_gpio_scl GPIO used for I2C clock (default "24") ++ ++ i2c_gpio_delay_us Clock delay in microseconds ++ (default "2" = ~100kHz) ++ ++ +Name: i2c-sensor +Info: Adds support for a number of I2C barometric pressure and temperature + sensors on i2c_arm +Load: dtoverlay=i2c-sensor,= -+Params: bmp085 Select the Bosch sensortronic BMP085 ++Params: addr Set the address for the BME280, BMP280, TMP102 ++ or LM75 + -+ bmp280 Select the Bosch sensortronic BMP280 ++ bme280 Select the Bosch Sensortronic BME280 ++ Valid addresses 0x76-0x77, default 0x76 ++ ++ bmp085 Select the Bosch Sensortronic BMP085 ++ ++ bmp180 Select the Bosch Sensortronic BMP180 ++ ++ bmp280 Select the Bosch Sensortronic BMP280 ++ Valid addresses 0x76-0x77, default 0x76 ++ ++ htu21 Select the HTU21 temperature and humidity sensor + + lm75 Select the Maxim LM75 temperature sensor ++ Valid addresses 0x48-0x4f, default 0x4f + -+ lm75addr Choose the address for the LM75 (0x48-0x4f - -+ default 0x4f) ++ lm75addr Deprecated - use addr parameter instead + + si7020 Select the Silicon Labs Si7013/20/21 humidity/ + temperature sensor + ++ tmp102 Select the Texas Instruments TMP102 temp sensor ++ Valid addresses 0x48-0x4b, default 0x48 ++ + +Name: i2c0-bcm2708 +Info: Enable the i2c_bcm2708 driver for the i2c0 bus. Not all pin combinations @@ -85405,6 +86395,13 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b +Params: + + ++Name: midi-uart1 ++Info: Configures UART1 (ttyS0) so that a requested 38.4kbaud actually gets ++ 31.25kbaud, the frequency required for MIDI ++Load: dtoverlay=midi-uart1 ++Params: ++ ++ +Name: mmc +Info: Selects the bcm2835-mmc SD/MMC driver, optionally with overclock +Load: dtoverlay=mmc,= @@ -85412,6 +86409,12 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b + requests 50MHz + + ++Name: mpu6050 ++Info: Overlay for i2c connected mpu6050 imu ++Load: dtoverlay=mpu6050,= ++Params: interrupt GPIO pin for interrupt (default 4) ++ ++ +Name: mz61581 +Info: MZ61581 display by Tontec +Load: dtoverlay=mz61581,= @@ -85636,6 +86639,15 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b +Params: + + ++Name: rotary-encoder ++Info: Overlay for GPIO connected rotary encoder. ++Load: dtoverlay=rotary-encoder,= ++Params: rotary0_pin_a GPIO connected to rotary encoder channel A ++ (default 4). ++ rotary0_pin_b GPIO connected to rotary encoder channel B ++ (default 17). ++ ++ +Name: rpi-backlight +Info: Raspberry Pi official display backlight driver +Load: dtoverlay=rpi-backlight @@ -85737,19 +86749,9 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b +Info: Selects the bcm2835-sdhost SD/MMC driver, optionally with overclock, + and enables SDIO via GPIOs 22-27. +Load: dtoverlay=sdio,= -+Params: overclock_50 SD Clock (in MHz) to use when the MMC framework -+ requests 50MHz -+ -+ sdio_overclock SDIO Clock (in MHz) to use when the MMC ++Params: sdio_overclock SDIO Clock (in MHz) to use when the MMC + framework requests 50MHz + -+ force_pio Disable DMA support (default off) -+ -+ pio_limit Number of blocks above which to use DMA -+ (default 1) -+ -+ debug Enable debug output (default off) -+ + poll_once Disable SDIO-device polling every second + (default on: polling once at boot-time) + @@ -85760,19 +86762,9 @@ index 0000000000000000000000000000000000000000..e2a803e5180cf78d67b6723cfd2f6d3b +Info: Selects the bcm2835-sdhost SD/MMC driver, optionally with overclock, + and enables 1-bit SDIO via GPIOs 22-25. +Load: dtoverlay=sdio-1bit,= -+Params: overclock_50 SD Clock (in MHz) to use when the MMC framework -+ requests 50MHz -+ -+ sdio_overclock SDIO Clock (in MHz) to use when the MMC ++Params: sdio_overclock SDIO Clock (in MHz) to use when the MMC + framework requests 50MHz + -+ force_pio Disable DMA support (default off) -+ -+ pio_limit Number of blocks above which to use DMA -+ (default 1) -+ -+ debug Enable debug output (default off) -+ + poll_once Disable SDIO-device polling every second + (default on: polling once at boot-time) + @@ -86588,6 +87580,56 @@ index 0000000000000000000000000000000000000000..ac1cfe093d9aa8a77ef25cc62a9d8100 + slave = <&boss_dac>,"allo,slave?"; + }; +}; +diff --git a/arch/arm/boot/dts/overlays/allo-digione-overlay.dts b/arch/arm/boot/dts/overlays/allo-digione-overlay.dts +new file mode 100644 +index 0000000000000000000000000000000000000000..101277a11a24e9b3eb441c44c3f19c61836fe77c +--- /dev/null ++++ b/arch/arm/boot/dts/overlays/allo-digione-overlay.dts +@@ -0,0 +1,44 @@ ++// Definitions for Allo DigiOne ++/dts-v1/; ++/plugin/; ++ ++/ { ++ compatible = "brcm,bcm2708"; ++ ++ fragment@0 { ++ target = <&i2s>; ++ __overlay__ { ++ status = "okay"; ++ }; ++ }; ++ ++ fragment@1 { ++ target = <&i2c1>; ++ __overlay__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ wm8804@3b { ++ #sound-dai-cells = <0>; ++ compatible = "wlf,wm8804"; ++ reg = <0x3b>; ++ PVDD-supply = <&vdd_3v3_reg>; ++ DVDD-supply = <&vdd_3v3_reg>; ++ status = "okay"; ++ wlf,reset-gpio = <&gpio 17 0>; ++ }; ++ }; ++ }; ++ ++ fragment@2 { ++ target = <&sound>; ++ __overlay__ { ++ compatible = "allo,allo-digione"; ++ i2s-controller = <&i2s>; ++ status = "okay"; ++ clock44-gpio = <&gpio 5 0>; ++ clock48-gpio = <&gpio 6 0>; ++ }; ++ }; ++}; diff --git a/arch/arm/boot/dts/overlays/allo-piano-dac-pcm512x-audio-overlay.dts b/arch/arm/boot/dts/overlays/allo-piano-dac-pcm512x-audio-overlay.dts new file mode 100644 index 0000000000000000000000000000000000000000..a5468d850a911cd509365cf25f8ffa6ad071b90a @@ -87399,6 +88441,58 @@ index 0000000000000000000000000000000000000000..81a07ed5a8c7594e65f0df2176418cac + }; + }; +}; +diff --git a/arch/arm/boot/dts/overlays/goodix-overlay.dts b/arch/arm/boot/dts/overlays/goodix-overlay.dts +new file mode 100644 +index 0000000000000000000000000000000000000000..084f74042ed6379ebd9281374d5391a7e23a431e +--- /dev/null ++++ b/arch/arm/boot/dts/overlays/goodix-overlay.dts +@@ -0,0 +1,46 @@ ++// Device tree overlay for I2C connected Goodix gt9271 multiple touch controller ++/dts-v1/; ++/plugin/; ++ ++/ { ++ compatible = "brcm,bcm2708"; ++ ++ fragment@0 { ++ target = <&gpio>; ++ __overlay__ { ++ goodix_pins: goodix_pins { ++ brcm,pins = <4 17>; // interrupt and reset ++ brcm,function = <0 0>; // in ++ brcm,pull = <2 2>; // pull-up ++ }; ++ }; ++ }; ++ ++ fragment@1 { ++ target = <&i2c1>; ++ __overlay__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ gt9271: gt9271@14 { ++ compatible = "goodix,gt9271"; ++ reg = <0x14>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&goodix_pins>; ++ interrupt-parent = <&gpio>; ++ interrupts = <4 2>; // high-to-low edge triggered ++ irq-gpios = <&gpio 4 0>; // Pin7 on GPIO header ++ reset-gpios = <&gpio 17 0>; // Pin11 on GPIO header ++ }; ++ }; ++ }; ++ ++ __overrides__ { ++ interrupt = <&goodix_pins>,"brcm,pins:0", ++ <>9271>,"interrupts:0", ++ <>9271>,"irq-gpios:4"; ++ reset = <&goodix_pins>,"brcm,pins:4", ++ <>9271>,"reset-gpios:4"; ++ }; ++}; diff --git a/arch/arm/boot/dts/overlays/googlevoicehat-soundcard-overlay.dts b/arch/arm/boot/dts/overlays/googlevoicehat-soundcard-overlay.dts new file mode 100644 index 0000000000000000000000000000000000000000..9a9e9a0ca28cf774a868b2882ae57b00de1cf7b7 @@ -87544,6 +88638,92 @@ index 0000000000000000000000000000000000000000..ff8cb36d94d4940d5151ace24afc4ad1 + active_low = <&power_ctrl>,"gpios:8"; + }; +}; +diff --git a/arch/arm/boot/dts/overlays/gpio-shutdown-overlay.dts b/arch/arm/boot/dts/overlays/gpio-shutdown-overlay.dts +new file mode 100644 +index 0000000000000000000000000000000000000000..863fb395c8539734b658682b900e1fbd96c9443e +--- /dev/null ++++ b/arch/arm/boot/dts/overlays/gpio-shutdown-overlay.dts +@@ -0,0 +1,80 @@ ++// Definitions for gpio-poweroff module ++/dts-v1/; ++/plugin/; ++ ++// This overlay sets up an input device that generates KEY_POWER events ++// when a given GPIO pin changes. It defaults to using GPIO3, which can ++// also be used to wake up (start) the Rpi again after shutdown. Since ++// wakeup is active-low, this defaults to active-low with a pullup ++// enabled, but all of this can be changed using overlay parameters (but ++// note that GPIO3 has an external pullup on at least some boards). ++ ++/ { ++ compatible = "brcm,bcm2708"; ++ ++ fragment@0 { ++ // Configure the gpio pin controller ++ target = <&gpio>; ++ __overlay__ { ++ // Define a pinctrl state, that sets up the gpio ++ // as an input with a pullup enabled. This does ++ // not take effect by itself, only when referenced ++ // by a "pinctrl client", as is done below. See: ++ // https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt ++ // https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/brcm,bcm2835-gpio.txt ++ pin_state: shutdown_button_pins { ++ brcm,pins = <3>; // gpio number ++ brcm,function = <0>; // 0 = input, 1 = output ++ brcm,pull = <2>; // 0 = none, 1 = pull down, 2 = pull up ++ }; ++ }; ++ }; ++ fragment@1 { ++ // Add a new device to the /soc devicetree node ++ target-path = "/soc"; ++ __overlay__ { ++ shutdown_button { ++ // Let the gpio-keys driver handle this device. See: ++ // https://www.kernel.org/doc/Documentation/devicetree/bindings/input/gpio-keys.txt ++ compatible = "gpio-keys"; ++ ++ // Declare a single pinctrl state (referencing the one declared above) and name it ++ // default, so it is activated automatically. ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pin_state>; ++ ++ // Enable this device ++ status = "okay"; ++ ++ // Define a single key, called "shutdown" that monitors the gpio and sends KEY_POWER ++ // (keycode 116, see ++ // https://github.com/torvalds/linux/blob/v4.12/include/uapi/linux/input-event-codes.h#L190) ++ button: shutdown { ++ label = "shutdown"; ++ linux,code = <116>; // KEY_POWER ++ gpios = <&gpio 3 1>; ++ }; ++ }; ++ }; ++ }; ++ ++ // This defines parameters that can be specified when loading ++ // the overlay. Each foo = line specifies one parameter, named ++ // foo. The rest of the specification gives properties where the ++ // parameter value is inserted into (changing the values above ++ // or adding new ones). ++ __overrides__ { ++ // Allow overriding the GPIO number. ++ gpio_pin = <&button>,"gpios:4", ++ <&pin_state>,"brcm,pins:0"; ++ ++ // Allow changing the internal pullup/down state. 0 = none, 1 = pulldown, 2 = pullup ++ // Note that GPIO3 and GPIO2 are the I2c pins and have an external pullup (at least ++ // on some boards). ++ gpio_pull = <&pin_state>,"brcm,pull:0"; ++ ++ // Allow setting the active_low flag. 0 = active high, 1 = active low ++ active_low = <&button>,"gpios:8"; ++ }; ++ ++}; diff --git a/arch/arm/boot/dts/overlays/hifiberry-amp-overlay.dts b/arch/arm/boot/dts/overlays/hifiberry-amp-overlay.dts new file mode 100644 index 0000000000000000000000000000000000000000..5f5785534fd3d9a97309796f842c8881e2d6979a @@ -88288,13 +89468,14 @@ index 0000000000000000000000000000000000000000..d1ffd2326669e46ad68939f94713cc99 + addr = <&pca>,"reg:0"; + }; +}; -diff --git a/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts b/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts +diff --git a/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts b/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts new file mode 100644 -index 0000000000000000000000000000000000000000..1efcf0b712c9c5c19210545002ac1f0931db58f5 +index 0000000000000000000000000000000000000000..8415e6081428fba9a47682964174fc023cfd2b0c --- /dev/null -+++ b/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts -@@ -0,0 +1,83 @@ ++++ b/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts +@@ -0,0 +1,183 @@ +// Definitions for several I2C based Real Time Clocks ++// Available through i2c-gpio +/dts-v1/; +/plugin/; + @@ -88302,8 +89483,23 @@ index 0000000000000000000000000000000000000000..1efcf0b712c9c5c19210545002ac1f09 + compatible = "brcm,bcm2708"; + + fragment@0 { -+ target = <&i2c_arm>; ++ target-path = "/"; + __overlay__ { ++ i2c_gpio: i2c-gpio-rtc@0 { ++ compatible = "i2c-gpio"; ++ gpios = <&gpio 23 0 /* sda */ ++ &gpio 24 0 /* scl */ ++ >; ++ i2c-gpio,delay-us = <2>; /* ~100 kHz */ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ }; ++ }; ++ ++ fragment@1 { ++ target = <&i2c_gpio>; ++ __dormant__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; @@ -88313,61 +89509,315 @@ index 0000000000000000000000000000000000000000..1efcf0b712c9c5c19210545002ac1f09 + reg = <0x69>; + abracon,tc-diode = "standard"; + abracon,tc-resistor = <0>; -+ status = "disable"; ++ status = "okay"; + }; ++ }; ++ }; ++ ++ fragment@2 { ++ target = <&i2c_gpio>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ + ds1307: ds1307@68 { + compatible = "maxim,ds1307"; + reg = <0x68>; -+ status = "disable"; ++ status = "okay"; + }; ++ }; ++ }; ++ ++ fragment@3 { ++ target = <&i2c_gpio>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ + ds1339: ds1339@68 { + compatible = "dallas,ds1339"; + trickle-resistor-ohms = <0>; + reg = <0x68>; -+ status = "disable"; -+ }; -+ mcp7940x: mcp7940x@6f { -+ compatible = "microchip,mcp7940x"; -+ reg = <0x6f>; -+ status = "disable"; -+ }; -+ mcp7941x: mcp7941x@6f { -+ compatible = "microchip,mcp7941x"; -+ reg = <0x6f>; -+ status = "disable"; -+ }; -+ ds3231: ds3231@68 { -+ compatible = "maxim,ds3231"; -+ reg = <0x68>; -+ status = "disable"; -+ }; -+ pcf2127: pcf2127@51 { -+ compatible = "nxp,pcf2127"; -+ reg = <0x51>; -+ status = "disable"; -+ }; -+ pcf8523: pcf8523@68 { -+ compatible = "nxp,pcf8523"; -+ reg = <0x68>; -+ status = "disable"; -+ }; -+ pcf8563: pcf8563@51 { -+ compatible = "nxp,pcf8563"; -+ reg = <0x51>; -+ status = "disable"; ++ status = "okay"; + }; + }; + }; ++ ++ fragment@4 { ++ target = <&i2c_gpio>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ ds3231: ds3231@68 { ++ compatible = "maxim,ds3231"; ++ reg = <0x68>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@5 { ++ target = <&i2c_gpio>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ mcp7940x: mcp7940x@6f { ++ compatible = "microchip,mcp7940x"; ++ reg = <0x6f>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@6 { ++ target = <&i2c_gpio>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ mcp7941x: mcp7941x@6f { ++ compatible = "microchip,mcp7941x"; ++ reg = <0x6f>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@7 { ++ target = <&i2c_gpio>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ pcf2127: pcf2127@51 { ++ compatible = "nxp,pcf2127"; ++ reg = <0x51>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@8 { ++ target = <&i2c_gpio>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ pcf8523: pcf8523@68 { ++ compatible = "nxp,pcf8523"; ++ reg = <0x68>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@9 { ++ target = <&i2c_gpio>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ pcf8563: pcf8563@51 { ++ compatible = "nxp,pcf8563"; ++ reg = <0x51>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ + __overrides__ { -+ abx80x = <&abx80x>,"status"; -+ ds1307 = <&ds1307>,"status"; -+ ds1339 = <&ds1339>,"status"; -+ ds3231 = <&ds3231>,"status"; -+ mcp7940x = <&mcp7940x>,"status"; -+ mcp7941x = <&mcp7941x>,"status"; -+ pcf2127 = <&pcf2127>,"status"; -+ pcf8523 = <&pcf8523>,"status"; -+ pcf8563 = <&pcf8563>,"status"; ++ abx80x = <0>,"+1"; ++ ds1307 = <0>,"+2"; ++ ds1339 = <0>,"+3"; ++ ds3231 = <0>,"+4"; ++ mcp7940x = <0>,"+5"; ++ mcp7941x = <0>,"+6"; ++ pcf2127 = <0>,"+7"; ++ pcf8523 = <0>,"+8"; ++ pcf8563 = <0>,"+9"; ++ trickle-diode-type = <&abx80x>,"abracon,tc-diode"; ++ trickle-resistor-ohms = <&ds1339>,"trickle-resistor-ohms:0", ++ <&abx80x>,"abracon,tc-resistor"; ++ wakeup-source = <&ds1339>,"wakeup-source?", ++ <&ds3231>,"wakeup-source?", ++ <&mcp7940x>,"wakeup-source?", ++ <&mcp7941x>,"wakeup-source?"; ++ i2c_gpio_sda = <&i2c_gpio>,"gpios:4"; ++ i2c_gpio_scl = <&i2c_gpio>,"gpios:16"; ++ i2c_gpio_delay_us = <&i2c_gpio>,"i2c-gpio,delay-us:0"; ++ }; ++}; +diff --git a/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts b/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts +new file mode 100644 +index 0000000000000000000000000000000000000000..6140f172a86b8731782f938f76cb5dac9f28b662 +--- /dev/null ++++ b/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts +@@ -0,0 +1,164 @@ ++// Definitions for several I2C based Real Time Clocks ++/dts-v1/; ++/plugin/; ++ ++/ { ++ compatible = "brcm,bcm2708"; ++ ++ fragment@0 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ abx80x: abx80x@69 { ++ compatible = "abracon,abx80x"; ++ reg = <0x69>; ++ abracon,tc-diode = "standard"; ++ abracon,tc-resistor = <0>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@1 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ ds1307: ds1307@68 { ++ compatible = "maxim,ds1307"; ++ reg = <0x68>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@2 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ ds1339: ds1339@68 { ++ compatible = "dallas,ds1339"; ++ trickle-resistor-ohms = <0>; ++ reg = <0x68>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@3 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ ds3231: ds3231@68 { ++ compatible = "maxim,ds3231"; ++ reg = <0x68>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@4 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ mcp7940x: mcp7940x@6f { ++ compatible = "microchip,mcp7940x"; ++ reg = <0x6f>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@5 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ mcp7941x: mcp7941x@6f { ++ compatible = "microchip,mcp7941x"; ++ reg = <0x6f>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@6 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ pcf2127: pcf2127@51 { ++ compatible = "nxp,pcf2127"; ++ reg = <0x51>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@7 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ pcf8523: pcf8523@68 { ++ compatible = "nxp,pcf8523"; ++ reg = <0x68>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@8 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ pcf8563: pcf8563@51 { ++ compatible = "nxp,pcf8563"; ++ reg = <0x51>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ __overrides__ { ++ abx80x = <0>,"+0"; ++ ds1307 = <0>,"+1"; ++ ds1339 = <0>,"+2"; ++ ds3231 = <0>,"+3"; ++ mcp7940x = <0>,"+4"; ++ mcp7941x = <0>,"+5"; ++ pcf2127 = <0>,"+6"; ++ pcf8523 = <0>,"+7"; ++ pcf8563 = <0>,"+8"; + trickle-diode-type = <&abx80x>,"abracon,tc-diode"; + trickle-resistor-ohms = <&ds1339>,"trickle-resistor-ohms:0", + <&abx80x>,"abracon,tc-resistor"; @@ -88379,11 +89829,11 @@ index 0000000000000000000000000000000000000000..1efcf0b712c9c5c19210545002ac1f09 +}; diff --git a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts new file mode 100644 -index 0000000000000000000000000000000000000000..606b2d5012abf2e85712be631c42ea40a0b512c5 +index 0000000000000000000000000000000000000000..17c27e3b666a7a83619471b50c63bb93836653c5 --- /dev/null +++ b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -@@ -0,0 +1,49 @@ -+// Definitions for I2C based sensors using the Industrial IO interface. +@@ -0,0 +1,142 @@ ++// Definitions for I2C based sensors using the Industrial IO or HWMON interface. +/dts-v1/; +/plugin/; + @@ -88392,7 +89842,22 @@ index 0000000000000000000000000000000000000000..606b2d5012abf2e85712be631c42ea40 + + fragment@0 { + target = <&i2c_arm>; -+ __overlay__ { ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ bme280: bme280@76 { ++ compatible = "bosch,bme280"; ++ reg = <0x76>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@1 { ++ target = <&i2c_arm>; ++ __dormant__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; @@ -88401,35 +89866,113 @@ index 0000000000000000000000000000000000000000..606b2d5012abf2e85712be631c42ea40 + compatible = "bosch,bmp085"; + reg = <0x77>; + default-oversampling = <3>; -+ status = "disable"; ++ status = "okay"; + }; ++ }; ++ }; ++ ++ fragment@2 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ bmp180: bmp180@77 { ++ compatible = "bosch,bmp180"; ++ reg = <0x77>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@3 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; + + bmp280: bmp280@76 { + compatible = "bosch,bmp280"; + reg = <0x76>; -+ status = "disable"; ++ status = "okay"; + }; ++ }; ++ }; ++ ++ fragment@4 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ htu21: htu21@40 { ++ compatible = "htu21"; ++ reg = <0x40>; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@5 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; + + lm75: lm75@4f { + compatible = "lm75"; + reg = <0x4f>; -+ status = "disable"; ++ status = "okay"; + }; ++ }; ++ }; ++ ++ fragment@6 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; + + si7020: si7020@40 { + compatible = "si7020"; + reg = <0x40>; -+ status = "disable"; ++ status = "okay"; ++ }; ++ }; ++ }; ++ ++ fragment@7 { ++ target = <&i2c_arm>; ++ __dormant__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ tmp102: tmp102@48 { ++ compatible = "ti,tmp102"; ++ reg = <0x48>; ++ status = "okay"; + }; + }; + }; + + __overrides__ { -+ bmp085 = <&bmp085>,"status"; -+ bmp280 = <&bmp280>,"status"; -+ lm75 = <&lm75>,"status"; ++ addr = <&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0", ++ <&lm75>,"reg:0"; ++ bme280 = <0>,"+0"; ++ bmp085 = <0>,"+1"; ++ bmp180 = <0>,"+2"; ++ bmp280 = <0>,"+3"; ++ htu21 = <0>,"+4"; ++ lm75 = <0>,"+5"; + lm75addr = <&lm75>,"reg:0"; -+ si7020 = <&si7020>,"status"; ++ si7020 = <0>,"+6"; ++ tmp102 = <0>,"+7"; + }; +}; diff --git a/arch/arm/boot/dts/overlays/i2c0-bcm2708-overlay.dts b/arch/arm/boot/dts/overlays/i2c0-bcm2708-overlay.dts @@ -88501,10 +90044,10 @@ index 0000000000000000000000000000000000000000..1f4fc7b570604a50ff6d3f6d676c3c46 +}; diff --git a/arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts b/arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts new file mode 100644 -index 0000000000000000000000000000000000000000..e303b9c61c82a28eab7b48f6b085661574d5a849 +index 0000000000000000000000000000000000000000..7c69047bcd88a5c900dddd08e60ad0750b96d785 --- /dev/null +++ b/arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts -@@ -0,0 +1,37 @@ +@@ -0,0 +1,34 @@ +/* + * Device tree overlay for i2c_bcm2708, i2c1 bus + * @@ -88527,19 +90070,16 @@ index 0000000000000000000000000000000000000000..e303b9c61c82a28eab7b48f6b0856615 + }; + + fragment@1 { -+ target = <&gpio>; -+ __overlay__ { -+ i2c1_pins: i2c1 { -+ brcm,pins = <2 3>; -+ brcm,function = <4>; /* alt0 */ -+ }; ++ target = <&i2c1_pins>; ++ pins: __overlay__ { ++ brcm,pins = <2 3>; ++ brcm,function = <4>; /* alt 0 */ + }; + }; -+ + __overrides__ { -+ sda1_pin = <&i2c1_pins>,"brcm,pins:0"; -+ scl1_pin = <&i2c1_pins>,"brcm,pins:4"; -+ pin_func = <&i2c1_pins>,"brcm,function:0"; ++ sda1_pin = <&pins>,"brcm,pins:0"; ++ scl1_pin = <&pins>,"brcm,pins:4"; ++ pin_func = <&pins>,"brcm,function:0"; + }; +}; diff --git a/arch/arm/boot/dts/overlays/i2s-gpio28-31-overlay.dts b/arch/arm/boot/dts/overlays/i2s-gpio28-31-overlay.dts @@ -90097,6 +91637,55 @@ index 0000000000000000000000000000000000000000..565af7cf79d761877be3bd06191f31aa + }; + }; +}; +diff --git a/arch/arm/boot/dts/overlays/midi-uart1-overlay.dts b/arch/arm/boot/dts/overlays/midi-uart1-overlay.dts +new file mode 100644 +index 0000000000000000000000000000000000000000..e0bc410acbff3a7a175dd5d53b3ab0d0802e8239 +--- /dev/null ++++ b/arch/arm/boot/dts/overlays/midi-uart1-overlay.dts +@@ -0,0 +1,43 @@ ++/dts-v1/; ++/plugin/; ++ ++#include ++ ++/* ++ * Fake a higher clock rate to get a larger divisor, and thereby a lower ++ * baudrate. The real clock is 48MHz, which we scale so that requesting ++ * 38.4kHz results in an actual 31.25kHz. ++ * ++ * 48000000*38400/31250 = 58982400 ++ */ ++ ++/{ ++ compatible = "brcm,bcm2835"; ++ ++ fragment@0 { ++ target-path = "/clocks"; ++ __overlay__ { ++ midi_clk: clock@5 { ++ compatible = "fixed-factor-clock"; ++ #clock-cells = <0>; ++ clocks = <&aux BCM2835_AUX_CLOCK_UART>; ++ clock-mult = <38400>; ++ clock-div = <31250>; ++ }; ++ }; ++ }; ++ ++ fragment@1 { ++ target = <&uart1>; ++ __overlay__ { ++ clocks = <&midi_clk>; ++ }; ++ }; ++ ++ fragment@2 { ++ target = <&aux>; ++ __overlay__ { ++ clock-output-names = "aux_uart", "aux_spi1", "aux_spi2"; ++ }; ++ }; ++}; diff --git a/arch/arm/boot/dts/overlays/mmc-overlay.dts b/arch/arm/boot/dts/overlays/mmc-overlay.dts new file mode 100644 index 0000000000000000000000000000000000000000..88251ad653917674f80c2975de2e425fca00b71f @@ -90142,6 +91731,40 @@ index 0000000000000000000000000000000000000000..88251ad653917674f80c2975de2e425f + overclock_50 = <&frag0>,"brcm,overclock-50:0"; + }; +}; +diff --git a/arch/arm/boot/dts/overlays/mpu6050-overlay.dts b/arch/arm/boot/dts/overlays/mpu6050-overlay.dts +new file mode 100644 +index 0000000000000000000000000000000000000000..06037969c3abba270b3cad45875342f3c730506e +--- /dev/null ++++ b/arch/arm/boot/dts/overlays/mpu6050-overlay.dts +@@ -0,0 +1,28 @@ ++// Definitions for MPU6050 ++/dts-v1/; ++/plugin/; ++ ++/ { ++ compatible = "brcm,bcm2708"; ++ ++ fragment@0 { ++ target = <&i2c1>; ++ __overlay__ { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ clock-frequency = <400000>; ++ ++ mpu6050: mpu6050@68 { ++ compatible = "invensense,mpu6050"; ++ reg = <0x68>; ++ interrupt-parent = <&gpio>; ++ interrupts = <4 1>; ++ }; ++ }; ++ }; ++ ++ __overrides__ { ++ interrupt = <&mpu6050>,"interrupts:0"; ++ }; ++}; diff --git a/arch/arm/boot/dts/overlays/mz61581-overlay.dts b/arch/arm/boot/dts/overlays/mz61581-overlay.dts new file mode 100644 index 0000000000000000000000000000000000000000..2c29aaed44c5959d7f0df2a3baf2af052b24b6b4 @@ -91467,6 +93090,55 @@ index 0000000000000000000000000000000000000000..2c3c97813f22c94eff6da2193aff0920 + }; + }; +}; +diff --git a/arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts b/arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts +new file mode 100644 +index 0000000000000000000000000000000000000000..c0c6bccff60cc15d9a9bf59d2c7cba41eb9c1cdc +--- /dev/null ++++ b/arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts +@@ -0,0 +1,43 @@ ++// Device tree overlay for GPIO connected rotary encoder. ++/dts-v1/; ++/plugin/; ++ ++/ { ++ compatible = "brcm,bcm2708"; ++ ++ fragment@0 { ++ target = <&gpio>; ++ __overlay__ { ++ rotary0_pins: rotary0_pins { ++ brcm,pins = <4 17>; /* gpio 4 17 */ ++ brcm,function = <0 0>; /* input */ ++ brcm,pull = <2 2>; /* pull-up */ ++ }; ++ ++ }; ++ }; ++ ++ fragment@1 { ++ target-path = "/"; ++ __overlay__ { ++ rotary0: rotary@0 { ++ compatible = "rotary-encoder"; ++ status = "okay"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&rotary0_pins>; ++ gpios = <&gpio 4 0>, <&gpio 17 0>; ++ linux,axis = <0>; /* REL_X */ ++ rotary-encoder,encoding = "gray"; ++ rotary-encoder,relative-axis; ++ }; ++ }; ++ ++ }; ++ ++ __overrides__ { ++ rotary0_pin_a = <&rotary0>,"gpios:4", ++ <&rotary0_pins>,"brcm,pins:0"; ++ rotary0_pin_b = <&rotary0>,"gpios:16", ++ <&rotary0_pins>,"brcm,pins:4"; ++ }; ++}; diff --git a/arch/arm/boot/dts/overlays/rpi-backlight-overlay.dts b/arch/arm/boot/dts/overlays/rpi-backlight-overlay.dts new file mode 100644 index 0000000000000000000000000000000000000000..c021d02bb75ff5ceb5c5066d00e4bca942554032 @@ -93267,7 +94939,7 @@ index 0000000000000000000000000000000000000000..fa73e1feaeb1bf53a6755e81a998e71c +}; diff --git a/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts b/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts new file mode 100644 -index 0000000000000000000000000000000000000000..95a595a35cb4fbb707bf4b18161f6a46860aa4ae +index 0000000000000000000000000000000000000000..36fbf6c8c2e612a6dc5aa02d77cc8173098c16ca --- /dev/null +++ b/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts @@ -0,0 +1,89 @@ @@ -93284,35 +94956,35 @@ index 0000000000000000000000000000000000000000..95a595a35cb4fbb707bf4b18161f6a46 + fragment@0 { + target-path = "/chosen"; + __overlay__ { -+ bootargs = "cma=256M@256M"; ++ bootargs = "cma=256M"; + }; + }; + + fragment@1 { + target-path = "/chosen"; + __dormant__ { -+ bootargs = "cma=192M@256M"; ++ bootargs = "cma=192M"; + }; + }; + + fragment@2 { + target-path = "/chosen"; + __dormant__ { -+ bootargs = "cma=128M@128M"; ++ bootargs = "cma=128M"; + }; + }; + + fragment@3 { + target-path = "/chosen"; + __dormant__ { -+ bootargs = "cma=96M@128M"; ++ bootargs = "cma=96M"; + }; + }; + + fragment@4 { + target-path = "/chosen"; + __dormant__ { -+ bootargs = "cma=64M@64M"; ++ bootargs = "cma=64M"; + }; + }; + @@ -93750,10 +95422,10 @@ index 58c05e5d9870b6c18a72da7dc44ff3112994946d..9842523b225a88505d796cc689c04f40 # Bzip2 -From e4e9fdf96b298ae5f105873a2da8dc9eacf43a82 Mon Sep 17 00:00:00 2001 +From 7d2419fe14520e8c16bc9774196f876552f1b282 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Fri, 6 Feb 2015 13:50:57 +0000 -Subject: [PATCH 053/199] BCM270x_DT: Add pwr_led, and the required "input" +Subject: [PATCH 058/129] BCM270x_DT: Add pwr_led, and the required "input" trigger The "input" trigger makes the associated GPIO an input. This is to support @@ -93928,10 +95600,10 @@ index 64c56d454f7df9f864a5242ce4212df586f66886..3fd74c8737871cb56f0355c858fc135e /* set_brightness_work / blink_timer flags, atomic, private. */ unsigned long work_flags; -From 0134f80b9e4f4886bc47c824a98d9eb60df581bd Mon Sep 17 00:00:00 2001 +From 9a26bfaab4ad8bd052a8f59dc9d8993dbb8b9fed Mon Sep 17 00:00:00 2001 From: Siarhei Siamashka Date: Mon, 17 Jun 2013 13:32:11 +0300 -Subject: [PATCH 054/199] fbdev: add FBIOCOPYAREA ioctl +Subject: [PATCH 059/129] fbdev: add FBIOCOPYAREA ioctl Based on the patch authored by Ali Gholami Rudi at https://lkml.org/lkml/2009/7/13/153 @@ -94199,10 +95871,10 @@ index fb795c3b3c178ad3cd7c9e9e4547ffd492bac181..703fa8a70574323abe2fb32599254582 __u32 dx; /* screen-relative */ __u32 dy; -From b3cd2630679656e1ebf8110ec0d8c815a1605305 Mon Sep 17 00:00:00 2001 +From 43d7209556b61a818e15c77d72de6bb7548a5761 Mon Sep 17 00:00:00 2001 From: Harm Hanemaaijer Date: Thu, 20 Jun 2013 20:21:39 +0200 -Subject: [PATCH 055/199] Speed up console framebuffer imageblit function +Subject: [PATCH 060/129] Speed up console framebuffer imageblit function Especially on platforms with a slower CPU but a relatively high framebuffer fill bandwidth, like current ARM devices, the existing @@ -94411,10 +96083,10 @@ index a2bb276a8b2463eee98eb237c4647bc00cd93601..436494fba15abecb400ef28688466faf start_index, pitch_index); } else -From 22578d48c455b5fec9cf2b84b8c7f0fa6c76b7dd Mon Sep 17 00:00:00 2001 +From 042d112e55c00d8ae7f286046b57d2ddd1384623 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Wed, 8 May 2013 11:46:50 +0100 -Subject: [PATCH 056/199] enabling the realtime clock 1-wire chip DS1307 and +Subject: [PATCH 061/129] enabling the realtime clock 1-wire chip DS1307 and 1-wire on GPIO4 (as a module) 1-wire: Add support for configuring pin for w1-gpio kernel module @@ -94664,10 +96336,10 @@ index 90cbe7e65059f6b604a87c6bf39cd9bbeae7684c..a52be51ee0a5511a75d4eaa8dacaec5e u8, w1_slave_found_callback); }; -From 23e1f567155092f061d3d38276f0cd687b5c9e83 Mon Sep 17 00:00:00 2001 +From 2cc6a69a583cb3acc2d7a2e316fa44ff1c0686b6 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Mon, 14 Jul 2014 22:02:09 +0100 -Subject: [PATCH 057/199] hid: Reduce default mouse polling interval to 60Hz +Subject: [PATCH 062/129] hid: Reduce default mouse polling interval to 60Hz Reduces overhead when using X --- @@ -94699,10 +96371,10 @@ index c008847e0b20a2accb00451b10fb1c648f67925b..4a86428a3b4e3d51e9ac6ce9c9c11097 break; case HID_GD_JOYSTICK: -From c9d870633a4f03f4cc0b38795005ef7baad96913 Mon Sep 17 00:00:00 2001 +From e150996c934660931e40cfdb468214a6644fa72e Mon Sep 17 00:00:00 2001 From: Gordon Hollingworth Date: Tue, 12 May 2015 14:47:56 +0100 -Subject: [PATCH 058/199] rpi-ft5406: Add touchscreen driver for pi LCD display +Subject: [PATCH 063/129] rpi-ft5406: Add touchscreen driver for pi LCD display Fix driver detection failure Check that the buffer response is non-zero meaning the touchscreen was detected @@ -95060,10 +96732,10 @@ index 30fb37fe175df604a738258a2a632bca3bfff33f..4a3d79d3b48eb483a4e4bf498f617515 RPI_FIRMWARE_FRAMEBUFFER_SET_BACKLIGHT = 0x0004800f, -From ba7812c211cefae21ae8306d758968dc53c96ea4 Mon Sep 17 00:00:00 2001 +From c0f35fbee29bc94de57a819bb31ee7f04e819c3d Mon Sep 17 00:00:00 2001 From: popcornmix Date: Mon, 28 Nov 2016 16:50:04 +0000 -Subject: [PATCH 059/199] Improve __copy_to_user and __copy_from_user +Subject: [PATCH 064/129] Improve __copy_to_user and __copy_from_user performance Provide a __copy_from_user that uses memcpy. On BCM2708, use @@ -96638,10 +98310,10 @@ index 17ec37811c32f09126ed42753037e055c5cec115..c08f81812d0d56a0d90c1eb6777d0622 bool "Broadcom BCM63xx DSL SoC" depends on ARCH_MULTI_V7 -From a482095b44fc466ef5413acdc5b018e239f9b86f Mon Sep 17 00:00:00 2001 +From 3ff9947d7af341718091959a025eab82abfd0d79 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 25 Jun 2015 12:16:11 +0100 -Subject: [PATCH 060/199] gpio-poweroff: Allow it to work on Raspberry Pi +Subject: [PATCH 065/129] gpio-poweroff: Allow it to work on Raspberry Pi The Raspberry Pi firmware manages the power-down and reboot process. To do this it installs a pm_power_off handler, causing @@ -96676,10 +98348,10 @@ index be3d81ff51cc3f510d85e4eed7a52960e51e7bc1..a030ae9fb1fca325061c093696e82186 "%s: pm_power_off function already registered", __func__); -From e46351a7c352589fadd3f09ef0f64d1e2890e355 Mon Sep 17 00:00:00 2001 +From d37d450d370dd100442281c2e6c3beae62f29db1 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Tue, 14 Jul 2015 14:32:47 +0100 -Subject: [PATCH 061/199] mfd: Add Raspberry Pi Sense HAT core driver +Subject: [PATCH 066/129] mfd: Add Raspberry Pi Sense HAT core driver --- drivers/input/joystick/Kconfig | 8 + @@ -97544,10 +99216,10 @@ index 0000000000000000000000000000000000000000..56196dc2af10e464a1e3f98b028dca1c + +#endif -From 8fe782927b4e226c4b5de92a5edcf60609abf0d3 Mon Sep 17 00:00:00 2001 +From 3f730e36e6c7f445aa3322d256cc1d20e507fb22 Mon Sep 17 00:00:00 2001 From: Florian Meier Date: Fri, 22 Nov 2013 19:19:08 +0100 -Subject: [PATCH 062/199] ASoC: Add support for HifiBerry DAC +Subject: [PATCH 067/129] ASoC: Add support for HifiBerry DAC This adds a machine driver for the HifiBerry DAC. It is a sound card that can @@ -97722,10 +99394,10 @@ index 0000000000000000000000000000000000000000..ee9f133953544629282631e5ef3f73fe +MODULE_DESCRIPTION("ASoC Driver for HifiBerry DAC"); +MODULE_LICENSE("GPL v2"); -From b828e0be04229dd55be53a90a8a4cf886fbe873b Mon Sep 17 00:00:00 2001 +From 822c013b4add8faace26366e5e0b833634a76624 Mon Sep 17 00:00:00 2001 From: Florian Meier Date: Mon, 25 Jan 2016 15:48:59 +0000 -Subject: [PATCH 063/199] ASoC: Add support for Rpi-DAC +Subject: [PATCH 068/129] ASoC: Add support for Rpi-DAC --- sound/soc/bcm/Kconfig | 7 +++ @@ -97891,7 +99563,7 @@ index 0000000000000000000000000000000000000000..38224467cbab7d5be3be731e73e2cf78 +MODULE_DESCRIPTION("ASoC Driver for RPi-DAC"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig -index 6c78b0b49b8145c24740d93c4174c059d91ddae9..d8b8cf059e8730432c692e8ce4e4fb9f1269550a 100644 +index d6450d5fc144737f967b8e00678baa9b8f92295f..bdd081016d9eca07a5c72bf238f22b85c3454013 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -108,6 +108,7 @@ config SND_SOC_ALL_CODECS @@ -98009,10 +99681,10 @@ index 0000000000000000000000000000000000000000..afe1b419582aa40c4b2729d242bb13cd +MODULE_AUTHOR("Florian Meier "); +MODULE_LICENSE("GPL v2"); -From 26f6ab87f4d58944fca7d44e0610817bd076dd7f Mon Sep 17 00:00:00 2001 +From 5b7c196681661799820cbcae36ff74ee4f1c0f16 Mon Sep 17 00:00:00 2001 From: Daniel Matuschek Date: Wed, 15 Jan 2014 21:41:23 +0100 -Subject: [PATCH 064/199] ASoC: wm8804: Implement MCLK configuration options, +Subject: [PATCH 069/129] ASoC: wm8804: Implement MCLK configuration options, add 32bit support WM8804 can run with PLL frequencies of 256xfs and 128xfs for most sample rates. At 192kHz only 128xfs is supported. The existing driver selects 128xfs automatically for some lower samples rates. By using an @@ -98061,10 +99733,10 @@ index af95d648265b3e92e345101542b332aee35191d4..513f56ba132929662802d15cdc653af3 .component_driver = { .dapm_widgets = wm8804_dapm_widgets, -From 56646d5f24756eca58ed3440b55ed429bc7142ea Mon Sep 17 00:00:00 2001 +From eb63ac8b4513898b305350779dcd03c5359841cb Mon Sep 17 00:00:00 2001 From: Daniel Matuschek Date: Wed, 15 Jan 2014 21:42:08 +0100 -Subject: [PATCH 065/199] ASoC: BCM:Add support for HiFiBerry Digi. Driver is +Subject: [PATCH 070/129] ASoC: BCM:Add support for HiFiBerry Digi. Driver is based on the patched WM8804 driver. Signed-off-by: Daniel Matuschek @@ -98408,10 +100080,10 @@ index 0000000000000000000000000000000000000000..7620dd02de40b6d644ff038b445d375d +MODULE_DESCRIPTION("ASoC Driver for HifiBerry Digi"); +MODULE_LICENSE("GPL v2"); -From b72345f423788161b0fc0756c154037ec9bd936f Mon Sep 17 00:00:00 2001 +From 9307ad8fccbfd25cf21b6528985e4826720a10bf Mon Sep 17 00:00:00 2001 From: Gordon Garrity Date: Sat, 8 Mar 2014 16:56:57 +0000 -Subject: [PATCH 066/199] Add IQaudIO Sound Card support for Raspberry Pi +Subject: [PATCH 071/129] Add IQaudIO Sound Card support for Raspberry Pi Set a limit of 0dB on Digital Volume Control @@ -98746,10 +100418,10 @@ index 0000000000000000000000000000000000000000..1ee4097c846376666775272ed692ca33 +MODULE_DESCRIPTION("ASoC Driver for IQAudio DAC"); +MODULE_LICENSE("GPL v2"); -From fb1da40f188d589a92d1dbd8f8e3651b046f8bb6 Mon Sep 17 00:00:00 2001 +From fbc0c13553e42eb4bc367d1bd16a53efb934977d Mon Sep 17 00:00:00 2001 From: Daniel Matuschek Date: Mon, 4 Aug 2014 10:06:56 +0200 -Subject: [PATCH 067/199] Added support for HiFiBerry DAC+ +Subject: [PATCH 072/129] Added support for HiFiBerry DAC+ The driver is based on the HiFiBerry DAC driver. However HiFiBerry DAC+ uses a different codec chip (PCM5122), therefore a new driver is necessary. @@ -99379,10 +101051,10 @@ index 72b19e62f6267698aea45d2410d616d91c1825cb..c6839ef6e16754ed9de2698507b8986a dev_err(dev, "No LRCLK?\n"); return -EINVAL; -From 07f31e445056ae254574bcb0aa5b137e313456ca Mon Sep 17 00:00:00 2001 +From 3c656fe05ad94ece55f0300040822d5fa289bf88 Mon Sep 17 00:00:00 2001 From: Daniel Matuschek Date: Mon, 4 Aug 2014 11:09:58 +0200 -Subject: [PATCH 068/199] Added driver for HiFiBerry Amp amplifier add-on board +Subject: [PATCH 073/129] Added driver for HiFiBerry Amp amplifier add-on board The driver contains a low-level hardware driver for the TAS5713 and the drivers for the Raspberry Pi I2S subsystem. @@ -99582,7 +101254,7 @@ index 0000000000000000000000000000000000000000..221c6c38e6465ffe5d5ad77fa80a0b14 +MODULE_DESCRIPTION("ASoC driver for HiFiBerry-AMP"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig -index d8b8cf059e8730432c692e8ce4e4fb9f1269550a..aca3a53f08dba8762307f7c25a5d7c5561b9cf71 100644 +index bdd081016d9eca07a5c72bf238f22b85c3454013..a3be6e005a895b995897cc007bb85c780a42de8b 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -150,6 +150,7 @@ config SND_SOC_ALL_CODECS @@ -100217,10 +101889,10 @@ index 0000000000000000000000000000000000000000..8f019e04898754d2f87e9630137be9e8 + +#endif /* _TAS5713_H */ -From 1af9d405621dac8d88598aa164a562fe8d6d538d Mon Sep 17 00:00:00 2001 +From 82ee4d398b7cabced98ca63a3f70f3473659ac04 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Wed, 25 Mar 2015 09:26:17 +0100 -Subject: [PATCH 069/199] Add driver for rpi-proto +Subject: [PATCH 074/129] Add driver for rpi-proto Forward port of 3.10.x driver from https://github.com/koalo We are using a custom board and would like to use rpi 3.18.x @@ -100435,10 +102107,10 @@ index 0000000000000000000000000000000000000000..fadbfade100228aaafabb0d3bdf35c01 +MODULE_DESCRIPTION("ASoC Driver for Raspberry Pi connected to PROTO board (WM8731)"); +MODULE_LICENSE("GPL"); -From b6103893ec46b0ff2b52844cf5d8ad6fd39fb89d Mon Sep 17 00:00:00 2001 +From e85b9da26bfa51d7dd014a04aacd8ee686d06af8 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Mon, 24 Aug 2015 16:03:47 +0100 -Subject: [PATCH 070/199] RaspiDAC3 support +Subject: [PATCH 075/129] RaspiDAC3 support Signed-off-by: Jan Grulich @@ -100681,10 +102353,10 @@ index 0000000000000000000000000000000000000000..ad2b5b89bc8213dc2e277306ef50d6e3 +MODULE_DESCRIPTION("ASoC Driver for RaspiDAC Rev.3x"); +MODULE_LICENSE("GPL v2"); -From 2e068793a621e2a7fbfb197fb21f789fcd5b455c Mon Sep 17 00:00:00 2001 +From 38ef14cf5946a797c88a64ef8360a22cf2c4d278 Mon Sep 17 00:00:00 2001 From: Aaron Shaw Date: Thu, 7 Apr 2016 21:26:21 +0100 -Subject: [PATCH 071/199] Add Support for JustBoom Audio boards +Subject: [PATCH 076/129] Add Support for JustBoom Audio boards justboom-dac: Adjust for ALSA API change @@ -101140,10 +102812,10 @@ index 0000000000000000000000000000000000000000..909cf8928f2f4313982316f9c5b8a709 +MODULE_DESCRIPTION("ASoC Driver for JustBoom PI Digi HAT Sound Card"); +MODULE_LICENSE("GPL v2"); -From b13456be95b5491610b2c3f90d51dd493e66fd07 Mon Sep 17 00:00:00 2001 +From f629bb3116976c649e97e435797ee09d39ed1e27 Mon Sep 17 00:00:00 2001 From: Andrey Grodzovsky Date: Tue, 3 May 2016 22:10:59 -0400 -Subject: [PATCH 072/199] ARM: adau1977-adc: Add basic machine driver for +Subject: [PATCH 077/129] ARM: adau1977-adc: Add basic machine driver for adau1977 codec driver. This commit adds basic support for the codec usage including: Device tree overlay, @@ -101325,10 +102997,10 @@ index 0000000000000000000000000000000000000000..f3d7e5db7bb912e1d7ca6f8e8d42df5f +MODULE_DESCRIPTION("ASoC Driver for ADAU1977 ADC"); +MODULE_LICENSE("GPL v2"); -From febd89d8cfbc208427f73be72677dab14ef0e7ff Mon Sep 17 00:00:00 2001 +From 6fbc69ecb541aeeb109dab802385e90efb71b48d Mon Sep 17 00:00:00 2001 From: Matt Flax Date: Mon, 16 May 2016 21:36:31 +1000 -Subject: [PATCH 073/199] New AudioInjector.net Pi soundcard with low jitter +Subject: [PATCH 078/129] New AudioInjector.net Pi soundcard with low jitter audio in and out. Contains the sound/soc/bcm ALSA machine driver and necessary alterations to the Kconfig and Makefile. @@ -101381,7 +103053,7 @@ index 8c20ce506f2b0d653be39ceb9224503a0ef63c39..4d4189b6d0c57645c5ec19554f1e77d4 + diff --git a/sound/soc/bcm/audioinjector-pi-soundcard.c b/sound/soc/bcm/audioinjector-pi-soundcard.c new file mode 100644 -index 0000000000000000000000000000000000000000..ef54e0f07ea03f59e9957b5d98f3e7fdc998e469 +index 0000000000000000000000000000000000000000..491906bbf446826e55dd843f28e4860f48e908b8 --- /dev/null +++ b/sound/soc/bcm/audioinjector-pi-soundcard.c @@ -0,0 +1,193 @@ @@ -101564,7 +103236,7 @@ index 0000000000000000000000000000000000000000..ef54e0f07ea03f59e9957b5d98f3e7fd + +static struct platform_driver audioinjector_pi_soundcard_driver = { + .driver = { -+ .name = "audioinjector-audio", ++ .name = "audioinjector-stereo", + .owner = THIS_MODULE, + .of_match_table = audioinjector_pi_soundcard_of_match, + }, @@ -101579,10 +103251,10 @@ index 0000000000000000000000000000000000000000..ef54e0f07ea03f59e9957b5d98f3e7fd +MODULE_ALIAS("platform:audioinjector-pi-soundcard"); + -From c60859b3ba64eb5f9f87d96fde38ffb9a2c2060b Mon Sep 17 00:00:00 2001 +From 69c13c876fb2ba99bb854f858c16b1b03281d586 Mon Sep 17 00:00:00 2001 From: DigitalDreamtime Date: Thu, 30 Jun 2016 18:38:42 +0100 -Subject: [PATCH 074/199] Add IQAudIO Digi WM8804 board support +Subject: [PATCH 079/129] Add IQAudIO Digi WM8804 board support Support IQAudIO Digi board with iqaudio_digi machine driver and iqaudio-digi-wm8804-audio overlay. @@ -101882,10 +103554,10 @@ index 0000000000000000000000000000000000000000..33aa2be8a43a12a12cfb5d844dd9732c +MODULE_DESCRIPTION("ASoC Driver for IQAudIO WM8804 Digi"); +MODULE_LICENSE("GPL v2"); -From 22f846750f606e1ed49912f3630940badd4fa217 Mon Sep 17 00:00:00 2001 +From ef454cce0ff5410983c63dd34258226b8ffaf0f1 Mon Sep 17 00:00:00 2001 From: escalator2015 Date: Tue, 24 May 2016 16:20:09 +0100 -Subject: [PATCH 075/199] New driver for RRA DigiDAC1 soundcard using WM8741 + +Subject: [PATCH 080/129] New driver for RRA DigiDAC1 soundcard using WM8741 + WM8804 --- @@ -102358,10 +104030,10 @@ index 0000000000000000000000000000000000000000..f200688bb4ae32b90a0ced555aed94b0 +MODULE_DESCRIPTION("ASoC Driver for RRA DigiDAC1"); +MODULE_LICENSE("GPL v2"); -From b728e43e3e797f3a7c866e00856ce444558b800c Mon Sep 17 00:00:00 2001 +From f5eda3e4747c90c99ffe1eb29d2abb824e4753bb Mon Sep 17 00:00:00 2001 From: DigitalDreamtime Date: Sat, 2 Jul 2016 16:26:19 +0100 -Subject: [PATCH 076/199] Add support for Dion Audio LOCO DAC-AMP HAT +Subject: [PATCH 081/129] Add support for Dion Audio LOCO DAC-AMP HAT Using dedicated machine driver and pcm5102a codec driver. @@ -102534,10 +104206,10 @@ index 0000000000000000000000000000000000000000..65e03741d349a2dc5bd91f69855ea952 +MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO"); +MODULE_LICENSE("GPL v2"); -From 167e7592ee54bb4e46e60414786b49d8e1bd90f0 Mon Sep 17 00:00:00 2001 +From ebff2709bd934a94f765aff4a361cef4ae03e30e Mon Sep 17 00:00:00 2001 From: Clive Messer Date: Mon, 19 Sep 2016 14:01:04 +0100 -Subject: [PATCH 077/199] Allo Piano DAC boards: Initial 2 channel (stereo) +Subject: [PATCH 082/129] Allo Piano DAC boards: Initial 2 channel (stereo) support (#1645) Add initial 2 channel (stereo) support for Allo Piano DAC (2.0/2.1) boards, @@ -102744,10 +104416,10 @@ index 0000000000000000000000000000000000000000..eaf50fb6dbca1970ae1c6f8662088b0f +MODULE_DESCRIPTION("ALSA ASoC Machine Driver for Allo Piano DAC"); +MODULE_LICENSE("GPL v2"); -From 52bcbfab198413486560cac989946a0a50d1a411 Mon Sep 17 00:00:00 2001 +From 52875cef71e2bb50bdb71172c5eb4e3f0c7e7db7 Mon Sep 17 00:00:00 2001 From: Raashid Muhammed Date: Mon, 27 Mar 2017 12:35:00 +0530 -Subject: [PATCH 078/199] Add support for Allo Piano DAC 2.1 plus add-on board +Subject: [PATCH 083/129] Add support for Allo Piano DAC 2.1 plus add-on board for Raspberry Pi. The Piano DAC 2.1 has support for 4 channels with subwoofer. @@ -102763,11 +104435,13 @@ Also improve code style and adhere to ALSA coding conventions. Signed-off-by: Baswaraj K Reviewed-by: Vijay Kumar B. Reviewed-by: Raashid Muhammed + +PianoPlus: Dual Mono & Dual Stereo features added (#2069) --- sound/soc/bcm/Kconfig | 7 + sound/soc/bcm/Makefile | 2 + - sound/soc/bcm/allo-piano-dac-plus.c | 683 ++++++++++++++++++++++++++++++++++++ - 3 files changed, 692 insertions(+) + sound/soc/bcm/allo-piano-dac-plus.c | 805 ++++++++++++++++++++++++++++++++++++ + 3 files changed, 814 insertions(+) create mode 100644 sound/soc/bcm/allo-piano-dac-plus.c diff --git a/sound/soc/bcm/Kconfig b/sound/soc/bcm/Kconfig @@ -102804,10 +104478,10 @@ index 64f007f8ba38276a42e0bd8db92544db9412544b..023b2c17098b4e64bb188a598f0b4923 +obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS) += snd-soc-allo-piano-dac-plus.o diff --git a/sound/soc/bcm/allo-piano-dac-plus.c b/sound/soc/bcm/allo-piano-dac-plus.c new file mode 100644 -index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3c08517eb +index 0000000000000000000000000000000000000000..d4e99e3c6a383d92fb0cf9e8c1cd1e7657358d49 --- /dev/null +++ b/sound/soc/bcm/allo-piano-dac-plus.c -@@ -0,0 +1,683 @@ +@@ -0,0 +1,805 @@ +/* + * ALSA ASoC Machine Driver for Allo Piano DAC Plus Subwoofer + * @@ -102846,6 +104520,7 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + +struct glb_pool { + struct mutex lock; ++ unsigned int dual_mode; + unsigned int set_lowpass; + unsigned int set_mode; + unsigned int set_rate; @@ -102857,8 +104532,8 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + +static struct gpio_desc *mute_gpio[2]; + -+ +static const char * const allo_piano_mode_texts[] = { ++ "None", + "2.0", + "2.1", + "2.2", @@ -102867,6 +104542,15 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 +static const SOC_ENUM_SINGLE_DECL(allo_piano_mode_enum, + 0, 0, allo_piano_mode_texts); + ++static const char * const allo_piano_dual_mode_texts[] = { ++ "None", ++ "Dual-Mono", ++ "Dual-Stereo", ++}; ++ ++static const SOC_ENUM_SINGLE_DECL(allo_piano_dual_mode_enum, ++ 0, 0, allo_piano_dual_mode_texts); ++ +static const char * const allo_piano_dsp_low_pass_texts[] = { + "60", + "70", @@ -102892,10 +104576,10 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + unsigned int mode, unsigned int rate, unsigned int lowpass) +{ + const struct firmware *fw; -+ char firmware_name[60]; -+ int ret = 0, dac = 0; + struct snd_soc_card *card = rtd->card; + struct glb_pool *glb_ptr = card->drvdata; ++ char firmware_name[60]; ++ int ret = 0, dac = 0; + + if (rate <= 46000) + rate = 44100; @@ -102910,26 +104594,35 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + else + rate = 192000; + -+ if ((lowpass > 14) || (lowpass < 0)) -+ lowpass = 3; -+ if ((mode > 2) || (mode < 0)) -+ mode = 0; ++ if (lowpass > 14) ++ glb_ptr->set_lowpass = lowpass = 3; ++ ++ if (mode > 3) ++ glb_ptr->set_mode = mode = 0; ++ ++ if (mode > 0) ++ glb_ptr->dual_mode = 0; + + /* same configuration loaded */ + if ((rate == glb_ptr->set_rate) && (lowpass == glb_ptr->set_lowpass) + && (mode == glb_ptr->set_mode)) + return 0; + -+ if (mode == 0) { /* 2.0 */ -+ snd_soc_write(rtd->codec_dais[1]->codec, -+ PCM512x_MUTE, 0x11); ++ switch (mode) { ++ case 0: /* None */ ++ return 1; ++ ++ case 1: /* 2.0 */ ++ snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x00); ++ snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x11); + glb_ptr->set_rate = rate; + glb_ptr->set_mode = mode; + glb_ptr->set_lowpass = lowpass; + return 1; -+ } else { -+ snd_soc_write(rtd->codec_dais[1]->codec, -+ PCM512x_MUTE, 0x00); ++ ++ default: ++ snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x00); ++ snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x00); + } + + for (dac = 0; dac < rtd->num_codecs; dac++) { @@ -102938,13 +104631,13 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + int i = 1; + + if (dac == 0) { /* high */ -+ sprintf(firmware_name, ++ snprintf(firmware_name, sizeof(firmware_name), + "allo/piano/2.2/allo-piano-dsp-%d-%d-%d.bin", + rate, ((lowpass * 10) + 60), dac); + } else { /* low */ -+ sprintf(firmware_name, ++ snprintf(firmware_name, sizeof(firmware_name), + "allo/piano/2.%d/allo-piano-dsp-%d-%d-%d.bin", -+ mode, rate, ((lowpass * 10) + 60), dac); ++ (mode - 1), rate, ((lowpass * 10) + 60), dac); + } + + dev_info(codec->dev, "Dsp Firmware File Name: %s\n", @@ -103009,6 +104702,80 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + return ret; +} + ++static int snd_allo_piano_dual_mode_get(struct snd_kcontrol *kcontrol, ++ struct snd_ctl_elem_value *ucontrol) ++{ ++ struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); ++ struct glb_pool *glb_ptr = card->drvdata; ++ ++ ucontrol->value.integer.value[0] = glb_ptr->dual_mode; ++ ++ return 0; ++} ++ ++static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol, ++ struct snd_ctl_elem_value *ucontrol) ++{ ++ struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); ++ struct glb_pool *glb_ptr = card->drvdata; ++ struct snd_soc_pcm_runtime *rtd; ++ struct snd_card *snd_card_ptr = card->snd_card; ++ struct snd_kcontrol *kctl; ++ struct soc_mixer_control *mc; ++ unsigned int left_val = 0; ++ ++ rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); ++ ++ if (ucontrol->value.integer.value[0] > 0) { ++ glb_ptr->dual_mode = ucontrol->value.integer.value[0]; ++ glb_ptr->set_mode = 0; ++ } else if (ucontrol->value.integer.value[0] <= 0) { ++ if (glb_ptr->set_mode <= 0) { ++ glb_ptr->dual_mode = 1; ++ glb_ptr->set_mode = 0; ++ } ++ } else { ++ glb_ptr->dual_mode = 0; ++ return 0; ++ } ++ ++ if (glb_ptr->dual_mode == 1) { ++ snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x01); ++ snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x10); ++ snd_soc_write(rtd->codec_dais[0]->codec, ++ PCM512x_DIGITAL_VOLUME_3, 0xff); ++ ++ list_for_each_entry(kctl, &snd_card_ptr->controls, list) { ++ if (!strncmp(kctl->id.name, "Digital Playback Volume", ++ sizeof(kctl->id.name))) { ++ mc = (struct soc_mixer_control *) ++ kctl->private_value; ++ mc->rreg = mc->reg; ++ break; ++ } ++ } ++ } else { ++ left_val = snd_soc_read(rtd->codec_dais[0]->codec, ++ PCM512x_DIGITAL_VOLUME_2); ++ list_for_each_entry(kctl, &snd_card_ptr->controls, list) { ++ if (!strncmp(kctl->id.name, "Digital Playback Volume", ++ sizeof(kctl->id.name))) { ++ mc = (struct soc_mixer_control *) ++ kctl->private_value; ++ mc->rreg = PCM512x_DIGITAL_VOLUME_3; ++ break; ++ } ++ } ++ ++ snd_soc_write(rtd->codec_dais[0]->codec, ++ PCM512x_DIGITAL_VOLUME_3, left_val); ++ snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x00); ++ snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x00); ++ } ++ ++ return 0; ++} ++ +static int snd_allo_piano_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ @@ -103025,8 +104792,30 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); + struct snd_soc_pcm_runtime *rtd; + struct glb_pool *glb_ptr = card->drvdata; ++ struct snd_card *snd_card_ptr = card->snd_card; ++ struct snd_kcontrol *kctl; ++ struct soc_mixer_control *mc; ++ unsigned int left_val = 0; + + rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); ++ ++ if ((glb_ptr->dual_mode == 1) && ++ (ucontrol->value.integer.value[0] > 0)) { ++ left_val = snd_soc_read(rtd->codec_dais[0]->codec, ++ PCM512x_DIGITAL_VOLUME_2); ++ list_for_each_entry(kctl, &snd_card_ptr->controls, list) { ++ if (!strncmp(kctl->id.name, "Digital Playback Volume", ++ sizeof(kctl->id.name))) { ++ mc = (struct soc_mixer_control *) ++ kctl->private_value; ++ mc->rreg = PCM512x_DIGITAL_VOLUME_3; ++ break; ++ } ++ } ++ snd_soc_write(rtd->codec_dais[0]->codec, ++ PCM512x_DIGITAL_VOLUME_3, left_val); ++ } ++ + return(snd_allo_piano_dsp_program(rtd, + ucontrol->value.integer.value[0], + glb_ptr->set_rate, glb_ptr->set_lowpass)); @@ -103154,6 +104943,11 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + snd_allo_piano_mode_get, + snd_allo_piano_mode_put), + ++ SOC_ENUM_EXT("Dual Mode Route", ++ allo_piano_dual_mode_enum, ++ snd_allo_piano_dual_mode_get, ++ snd_allo_piano_dual_mode_put), ++ + SOC_ENUM_EXT("Lowpass Route", allo_piano_enum, + snd_allo_piano_lowpass_get, + snd_allo_piano_lowpass_put), @@ -103282,7 +105076,7 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + PCM512x_RATE_DET_4); + if (val < 0) { + dev_err(rtd->codec_dais[dac]->codec->dev, -+ "Failed to read register PCM512x_RATE_DET_4\n"); ++ "Failed to read register PCM512x_RATE_DET_4\n"); + return val; + } + @@ -103292,7 +105086,7 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + PCM512x_SREF_BCK); + + dev_info(rtd->codec_dais[dac]->codec->dev, -+ "Setting BCLK as input clock & Enable PLL\n"); ++ "Setting BCLK as input clock & Enable PLL\n"); + } else { + snd_soc_write(rtd->codec_dais[dac]->codec, + PCM512x_PLL_EN, @@ -103303,7 +105097,7 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + PCM512x_SREF_SCK); + + dev_info(rtd->codec_dais[dac]->codec->dev, -+ "Setting SCLK as input clock & disabled PLL\n"); ++ "Setting SCLK as input clock & disabled PLL\n"); + } + } + @@ -103314,6 +105108,7 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + dev_warn(card->dev, "Failed to set volume limit: %d\n", + ret); + } ++ + ret = snd_allo_piano_dsp_program(rtd, glb_ptr->set_mode, rate, + glb_ptr->set_lowpass); + if (ret < 0) @@ -103331,6 +105126,7 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 + struct snd_soc_card *card = rtd->card; + + snd_allo_piano_gpio_unmute(card); ++ + return 0; +} + @@ -103492,11 +105288,11 @@ index 0000000000000000000000000000000000000000..56e43f98846b41e487b3089813f7edc3 +MODULE_DESCRIPTION("ALSA ASoC Machine Driver for Allo Piano DAC Plus"); +MODULE_LICENSE("GPL v2"); -From 56795e108b638269239778c9546b3e5125d4b216 Mon Sep 17 00:00:00 2001 +From e42b4e221249dd728e85fba984ff1cb8347e8be8 Mon Sep 17 00:00:00 2001 From: BabuSubashChandar Date: Tue, 28 Mar 2017 20:04:42 +0530 -Subject: [PATCH 079/199] Add support for Allo Boss DAC add-on board for - Raspberry Pi. (#1924) +Subject: [PATCH 084/129] Add support for Allo Boss DAC add-on board for + Raspberry Pi. (#1924) Signed-off-by: Baswaraj K Reviewed-by: Deepak @@ -104198,10 +105994,10 @@ index 0000000000000000000000000000000000000000..203ab76c7045b081578e23bda1099dd1 +MODULE_DESCRIPTION("ALSA ASoC Machine Driver for Allo Boss DAC"); +MODULE_LICENSE("GPL v2"); -From 305da1e20346a94876830a1c36991e482732d7e6 Mon Sep 17 00:00:00 2001 +From ba9487e8829443e63cd95c00b57492a1170754bf Mon Sep 17 00:00:00 2001 From: gtrainavicius Date: Sun, 23 Oct 2016 12:06:53 +0300 -Subject: [PATCH 080/199] Support for Blokas Labs pisound board +Subject: [PATCH 085/129] Support for Blokas Labs pisound board Pisound dynamic overlay (#1760) @@ -105400,10 +107196,10 @@ index 0000000000000000000000000000000000000000..06ff1e53dc9d860946965b6303577762 +MODULE_DESCRIPTION("ASoC Driver for pisound, http://blokas.io/pisound"); +MODULE_LICENSE("GPL v2"); -From 58114c260582ecc7b7c3d6193b807f25332aa485 Mon Sep 17 00:00:00 2001 +From c7ccddce5f413a68aaba65d3f3908b41b3e7da0f Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Sun, 22 Jan 2017 12:49:37 +0100 -Subject: [PATCH 081/199] ASoC: Add driver for Cirrus Logic Audio Card +Subject: [PATCH 086/129] ASoC: Add driver for Cirrus Logic Audio Card Note: due to problems with deferred probing of regulators the following softdep should be added to a modprobe.d file @@ -106468,10 +108264,10 @@ index 0000000000000000000000000000000000000000..ac8651ddff7bd3701dffe22c7fb88352 +MODULE_DESCRIPTION("ASoC driver for Cirrus Logic Audio Card"); +MODULE_LICENSE("GPL"); -From 1b6be09da4dc272f823629fed84e79834c47f73a Mon Sep 17 00:00:00 2001 +From f82b730b26f6626d9f1e261c792feb80c26837de Mon Sep 17 00:00:00 2001 From: Miquel Date: Fri, 24 Feb 2017 20:51:06 +0100 -Subject: [PATCH 082/199] sound: Support for Dion Audio LOCO-V2 DAC-AMP HAT +Subject: [PATCH 087/129] sound: Support for Dion Audio LOCO-V2 DAC-AMP HAT Signed-off-by: Miquel Blauw --- @@ -106666,10 +108462,10 @@ index 0000000000000000000000000000000000000000..a009c49477972a9832175d86f201b035 +MODULE_DESCRIPTION("ASoC Driver for DionAudio LOCO-V2"); +MODULE_LICENSE("GPL v2"); -From 12310f62bb4b4a5c89f021cca2115a83a7ee4b64 Mon Sep 17 00:00:00 2001 +From c6220b7c4674451da55a209557ebb87b5eaa14b6 Mon Sep 17 00:00:00 2001 From: Fe-Pi Date: Wed, 1 Mar 2017 04:42:43 -0700 -Subject: [PATCH 083/199] Add support for Fe-Pi audio sound card. (#1867) +Subject: [PATCH 088/129] Add support for Fe-Pi audio sound card. (#1867) Fe-Pi Audio Sound Card is based on NXP SGTL5000 codec. Mechanical specification of the board is the same the Raspberry Pi Zero. @@ -106883,10 +108679,10 @@ index 0000000000000000000000000000000000000000..015b56fd73cc36be5b5eecd17548fd03 +MODULE_DESCRIPTION("ASoC Driver for Fe-Pi Audio"); +MODULE_LICENSE("GPL v2"); -From c3fe735ad32332d59e31c96f687f578c36f79cab Mon Sep 17 00:00:00 2001 +From afd8236c2f127531902daad63f61afcae95f0a37 Mon Sep 17 00:00:00 2001 From: Matt Flax Date: Wed, 8 Mar 2017 20:04:13 +1100 -Subject: [PATCH 084/199] Add support for the AudioInjector.net Octo sound card +Subject: [PATCH 089/129] Add support for the AudioInjector.net Octo sound card AudioInjector Octo: sample rates, regulators, reset @@ -106897,11 +108693,16 @@ new supported rates are (in kHz) : Reference the bcm270x DT regulators in the overlay. This patch adds a reset GPIO for the AudioInjector.net octo sound card. + +Audioinjector octo : Make the playback and capture symmetric + +This patch ensures that the sample rate and channel count of the audioinjector +octo sound card are symmetric. --- sound/soc/bcm/Kconfig | 7 + sound/soc/bcm/Makefile | 2 + - sound/soc/bcm/audioinjector-octo-soundcard.c | 339 +++++++++++++++++++++++++++ - 3 files changed, 348 insertions(+) + sound/soc/bcm/audioinjector-octo-soundcard.c | 341 +++++++++++++++++++++++++++ + 3 files changed, 350 insertions(+) create mode 100644 sound/soc/bcm/audioinjector-octo-soundcard.c diff --git a/sound/soc/bcm/Kconfig b/sound/soc/bcm/Kconfig @@ -106944,10 +108745,10 @@ index c3feaf198d997935fdf6815f9f8555d8704e53af..113b6899dd9fd6c4a6f706f57e32201d obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO_V2) += snd-soc-dionaudio-loco-v2.o diff --git a/sound/soc/bcm/audioinjector-octo-soundcard.c b/sound/soc/bcm/audioinjector-octo-soundcard.c new file mode 100644 -index 0000000000000000000000000000000000000000..dcf403ab37639ba79e38278d7e4b1ade452c292a +index 0000000000000000000000000000000000000000..5e79f4eff93a21ed3495c77a90f73525695cb3d5 --- /dev/null +++ b/sound/soc/bcm/audioinjector-octo-soundcard.c -@@ -0,0 +1,339 @@ +@@ -0,0 +1,341 @@ +/* + * ASoC Driver for AudioInjector Pi octo channel soundcard (hat) + * @@ -107154,6 +108955,8 @@ index 0000000000000000000000000000000000000000..dcf403ab37639ba79e38278d7e4b1ade + .codec_dai_name = "cs42448", + .ops = &audioinjector_octo_ops, + .init = audioinjector_octo_dai_init, ++ .symmetric_rates = 1, ++ .symmetric_channels = 1, + }, +}; + @@ -107274,7 +109077,7 @@ index 0000000000000000000000000000000000000000..dcf403ab37639ba79e38278d7e4b1ade + +static struct platform_driver audioinjector_octo_driver = { + .driver = { -+ .name = "audioinjector-audio", ++ .name = "audioinjector-octo", + .owner = THIS_MODULE, + .of_match_table = audioinjector_octo_of_match, + }, @@ -107288,10 +109091,10 @@ index 0000000000000000000000000000000000000000..dcf403ab37639ba79e38278d7e4b1ade +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:audioinjector-octo-soundcard"); -From 34aa72ecf4c3bd091d7631cfba2d03066473bd02 Mon Sep 17 00:00:00 2001 +From 08d3e5a0ec754c239219af3f1f3d18913ea8cc35 Mon Sep 17 00:00:00 2001 From: Peter Malkin Date: Mon, 27 Mar 2017 16:38:21 -0700 -Subject: [PATCH 085/199] Driver support for Google voiceHAT soundcard. +Subject: [PATCH 090/129] Driver support for Google voiceHAT soundcard. --- sound/soc/bcm/Kconfig | 7 ++ @@ -107682,10 +109485,335 @@ index 0000000000000000000000000000000000000000..225854b8e5298b3c3018f59a49404354 +MODULE_DESCRIPTION("ASoC Driver for Google voiceHAT SoundCard"); +MODULE_LICENSE("GPL v2"); -From e8ceba81b9363e64a30ad6845594d86a75c1a0d4 Mon Sep 17 00:00:00 2001 +From 5926e0d83bb9c5bd15806fd81ea648bc90f3aab3 Mon Sep 17 00:00:00 2001 +From: sandeepal +Date: Fri, 2 Jun 2017 18:59:46 +0530 +Subject: [PATCH 091/129] Allo Digione Driver (#2048) + +Driver for the Allo Digione soundcard +--- + sound/soc/bcm/Kconfig | 7 ++ + sound/soc/bcm/Makefile | 2 + + sound/soc/bcm/allo-digione.c | 268 +++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 277 insertions(+) + create mode 100644 sound/soc/bcm/allo-digione.c + +diff --git a/sound/soc/bcm/Kconfig b/sound/soc/bcm/Kconfig +index 355bdeb25f81d15593f78df0e87a48404908ca4b..381d32bb9deb3cf2c531e2a4563418cd6eb9d505 100644 +--- a/sound/soc/bcm/Kconfig ++++ b/sound/soc/bcm/Kconfig +@@ -176,6 +176,13 @@ config SND_BCM2708_SOC_ALLO_BOSS_DAC + help + Say Y or M if you want to add support for Allo Boss DAC. + ++config SND_BCM2708_SOC_ALLO_DIGIONE ++ tristate "Support for Allo DigiOne" ++ depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S ++ select SND_SOC_PCM512x_I2C ++ help ++ Say Y or M if you want to add support for Allo DigiOne. ++ + config SND_BCM2708_SOC_FE_PI_AUDIO + tristate "Support for Fe-Pi-Audio" + depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S +diff --git a/sound/soc/bcm/Makefile b/sound/soc/bcm/Makefile +index 72e1620fa4038035804cf3b2a09c6b12e7ae0fe1..53ea8229d7ac2065176983385dd7ba85ee3915ea 100644 +--- a/sound/soc/bcm/Makefile ++++ b/sound/soc/bcm/Makefile +@@ -34,6 +34,7 @@ snd-soc-dionaudio-loco-v2-objs := dionaudio_loco-v2.o + snd-soc-allo-boss-dac-objs := allo-boss-dac.o + snd-soc-allo-piano-dac-objs := allo-piano-dac.o + snd-soc-allo-piano-dac-plus-objs := allo-piano-dac-plus.o ++snd-soc-allo-digione-objs := allo-digione.o + snd-soc-pisound-objs := pisound.o + snd-soc-fe-pi-audio-objs := fe-pi-audio.o + +@@ -60,5 +61,6 @@ obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO_V2) += snd-soc-dionaudio-loco-v2.o + obj-$(CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC) += snd-soc-allo-boss-dac.o + obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC) += snd-soc-allo-piano-dac.o + obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS) += snd-soc-allo-piano-dac-plus.o ++obj-$(CONFIG_SND_BCM2708_SOC_ALLO_DIGIONE) += snd-soc-allo-digione.o + obj-$(CONFIG_SND_PISOUND) += snd-soc-pisound.o + obj-$(CONFIG_SND_BCM2708_SOC_FE_PI_AUDIO) += snd-soc-fe-pi-audio.o +diff --git a/sound/soc/bcm/allo-digione.c b/sound/soc/bcm/allo-digione.c +new file mode 100644 +index 0000000000000000000000000000000000000000..e3664e44c699d0102120ecf99e8b780a4505ebad +--- /dev/null ++++ b/sound/soc/bcm/allo-digione.c +@@ -0,0 +1,268 @@ ++/* ++ * ASoC Driver for Allo DigiOne ++ * ++ * Author: Baswaraj ++ * Copyright 2017 ++ * based on code by Daniel Matuschek ++ * based on code by Florian Meier ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ */ ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "../codecs/wm8804.h" ++ ++static short int auto_shutdown_output = 0; ++module_param(auto_shutdown_output, short, ++ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); ++MODULE_PARM_DESC(auto_shutdown_output, "Shutdown SP/DIF output if playback is stopped"); ++ ++#define CLK_44EN_RATE 22579200UL ++#define CLK_48EN_RATE 24576000UL ++ ++static struct gpio_desc *snd_allo_clk44gpio; ++static struct gpio_desc *snd_allo_clk48gpio; ++ ++static int samplerate = 44100; ++ ++static uint32_t snd_allo_digione_enable_clock(int sample_rate) ++{ ++ switch (sample_rate) { ++ case 11025: ++ case 22050: ++ case 44100: ++ case 88200: ++ case 176400: ++ gpiod_set_value_cansleep(snd_allo_clk44gpio, 1); ++ gpiod_set_value_cansleep(snd_allo_clk48gpio, 0); ++ return CLK_44EN_RATE; ++ default: ++ gpiod_set_value_cansleep(snd_allo_clk48gpio, 1); ++ gpiod_set_value_cansleep(snd_allo_clk44gpio, 0); ++ return CLK_48EN_RATE; ++ } ++} ++ ++ ++static int snd_allo_digione_init(struct snd_soc_pcm_runtime *rtd) ++{ ++ struct snd_soc_codec *codec = rtd->codec; ++ ++ /* enable TX output */ ++ snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x0); ++ ++ return 0; ++} ++ ++static int snd_allo_digione_startup(struct snd_pcm_substream *substream) ++{ ++ /* turn on digital output */ ++ struct snd_soc_pcm_runtime *rtd = substream->private_data; ++ struct snd_soc_codec *codec = rtd->codec; ++ snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x00); ++ return 0; ++} ++ ++static void snd_allo_digione_shutdown(struct snd_pcm_substream *substream) ++{ ++ /* turn off output */ ++ if (auto_shutdown_output) { ++ /* turn off output */ ++ struct snd_soc_pcm_runtime *rtd = substream->private_data; ++ struct snd_soc_codec *codec = rtd->codec; ++ snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x3c); ++ } ++} ++ ++static int snd_allo_digione_hw_params(struct snd_pcm_substream *substream, ++ struct snd_pcm_hw_params *params) ++{ ++ struct snd_soc_pcm_runtime *rtd = substream->private_data; ++ struct snd_soc_dai *codec_dai = rtd->codec_dai; ++ struct snd_soc_codec *codec = rtd->codec; ++ struct snd_soc_dai *cpu_dai = rtd->cpu_dai; ++ ++ int sysclk = 27000000; /* This is fixed on this board */ ++ ++ long mclk_freq = 0; ++ int mclk_div = 1; ++ int sampling_freq = 1; ++ ++ int ret; ++ ++ samplerate = params_rate(params); ++ ++ if (samplerate <= 96000) { ++ mclk_freq = samplerate * 256; ++ mclk_div = WM8804_MCLKDIV_256FS; ++ } else { ++ mclk_freq = samplerate * 128; ++ mclk_div = WM8804_MCLKDIV_128FS; ++ } ++ ++ sysclk = snd_allo_digione_enable_clock(samplerate); ++ ++ switch (samplerate) { ++ case 32000: ++ sampling_freq=0x03; ++ break; ++ case 44100: ++ sampling_freq=0x00; ++ break; ++ case 48000: ++ sampling_freq=0x02; ++ break; ++ case 88200: ++ sampling_freq=0x08; ++ break; ++ case 96000: ++ sampling_freq=0x0a; ++ break; ++ case 176400: ++ sampling_freq=0x0c; ++ break; ++ case 192000: ++ sampling_freq=0x0e; ++ break; ++ default: ++ dev_err(codec->dev, ++ "Failed to set WM8804 SYSCLK, unsupported samplerate %d\n", ++ samplerate); ++ } ++ ++ snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div); ++ snd_soc_dai_set_pll(codec_dai, 0, 0, sysclk, mclk_freq); ++ ++ ret = snd_soc_dai_set_sysclk(codec_dai, WM8804_TX_CLKSRC_PLL, ++ sysclk, SND_SOC_CLOCK_OUT); ++ ++ if (ret < 0) { ++ dev_err(codec->dev, ++ "Failed to set WM8804 SYSCLK: %d\n", ret); ++ return ret; ++ } ++ ++ /* Enable TX output */ ++ snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x0); ++ ++ /* Power on */ ++ snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0); ++ ++ /* set sampling frequency status bits */ ++ snd_soc_update_bits(codec, WM8804_SPDTX4, 0x0f, sampling_freq); ++ ++ return snd_soc_dai_set_bclk_ratio(cpu_dai, 64); ++} ++ ++/* machine stream operations */ ++static struct snd_soc_ops snd_allo_digione_ops = { ++ .hw_params = snd_allo_digione_hw_params, ++ .startup = snd_allo_digione_startup, ++ .shutdown = snd_allo_digione_shutdown, ++}; ++ ++static struct snd_soc_dai_link snd_allo_digione_dai[] = { ++{ ++ .name = "Allo DigiOne", ++ .stream_name = "Allo DigiOne HiFi", ++ .cpu_dai_name = "bcm2708-i2s.0", ++ .codec_dai_name = "wm8804-spdif", ++ .platform_name = "bcm2708-i2s.0", ++ .codec_name = "wm8804.1-003b", ++ .dai_fmt = SND_SOC_DAIFMT_I2S | ++ SND_SOC_DAIFMT_NB_NF | ++ SND_SOC_DAIFMT_CBM_CFM, ++ .ops = &snd_allo_digione_ops, ++ .init = snd_allo_digione_init, ++}, ++}; ++ ++/* audio machine driver */ ++static struct snd_soc_card snd_allo_digione = { ++ .name = "snd_allo_digione", ++ .driver_name = "AlloDigiOne", ++ .owner = THIS_MODULE, ++ .dai_link = snd_allo_digione_dai, ++ .num_links = ARRAY_SIZE(snd_allo_digione_dai), ++}; ++ ++static int snd_allo_digione_probe(struct platform_device *pdev) ++{ ++ int ret = 0; ++ ++ snd_allo_digione.dev = &pdev->dev; ++ ++ if (pdev->dev.of_node) { ++ struct device_node *i2s_node; ++ struct snd_soc_dai_link *dai = &snd_allo_digione_dai[0]; ++ i2s_node = of_parse_phandle(pdev->dev.of_node, ++ "i2s-controller", 0); ++ ++ if (i2s_node) { ++ dai->cpu_dai_name = NULL; ++ dai->cpu_of_node = i2s_node; ++ dai->platform_name = NULL; ++ dai->platform_of_node = i2s_node; ++ } ++ ++ snd_allo_clk44gpio = ++ devm_gpiod_get(&pdev->dev, "clock44", GPIOD_OUT_LOW); ++ if (IS_ERR(snd_allo_clk44gpio)) ++ dev_err(&pdev->dev, "devm_gpiod_get() failed\n"); ++ ++ snd_allo_clk48gpio = ++ devm_gpiod_get(&pdev->dev, "clock48", GPIOD_OUT_LOW); ++ if (IS_ERR(snd_allo_clk48gpio)) ++ dev_err(&pdev->dev, "devm_gpiod_get() failed\n"); ++ } ++ ++ ret = snd_soc_register_card(&snd_allo_digione); ++ if (ret && ret != -EPROBE_DEFER) ++ dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ++ ret); ++ ++ return ret; ++} ++ ++static int snd_allo_digione_remove(struct platform_device *pdev) ++{ ++ return snd_soc_unregister_card(&snd_allo_digione); ++} ++ ++static const struct of_device_id snd_allo_digione_of_match[] = { ++ { .compatible = "allo,allo-digione", }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, snd_allo_digione_of_match); ++ ++static struct platform_driver snd_allo_digione_driver = { ++ .driver = { ++ .name = "snd-allo-digione", ++ .owner = THIS_MODULE, ++ .of_match_table = snd_allo_digione_of_match, ++ }, ++ .probe = snd_allo_digione_probe, ++ .remove = snd_allo_digione_remove, ++}; ++ ++module_platform_driver(snd_allo_digione_driver); ++ ++MODULE_AUTHOR("Baswaraj "); ++MODULE_DESCRIPTION("ASoC Driver for Allo DigiOne"); ++MODULE_LICENSE("GPL v2"); + +From 1ec00318fdec23f1feed3e7972ac8e7ab70d51d5 Mon Sep 17 00:00:00 2001 From: P33M Date: Wed, 21 Oct 2015 14:55:21 +0100 -Subject: [PATCH 086/199] rpi_display: add backlight driver and overlay +Subject: [PATCH 092/129] rpi_display: add backlight driver and overlay Add a mailbox-driven backlight controller for the Raspberry Pi DSI touchscreen display. Requires updated GPU firmware to recognise the @@ -107854,10 +109982,10 @@ index 0000000000000000000000000000000000000000..14a0d9b037395497c1fdae2961feccd5 +MODULE_DESCRIPTION("Raspberry Pi mailbox based Backlight Driver"); +MODULE_LICENSE("GPL"); -From a03f5c85a90929d12db1e9e30897a6436f386b38 Mon Sep 17 00:00:00 2001 +From 8b334bd0404a15a9ef5e1c58075855d2a17220a8 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Tue, 23 Feb 2016 19:56:04 +0000 -Subject: [PATCH 087/199] bcm2835-virtgpio: Virtual GPIO driver +Subject: [PATCH 093/129] bcm2835-virtgpio: Virtual GPIO driver Add a virtual GPIO driver that uses the firmware mailbox interface to request that the VPU toggles LEDs. @@ -108131,10 +110259,10 @@ index 4a3d79d3b48eb483a4e4bf498f617515e3ad158f..5f34e1257117fb48013c9926a8a223d6 RPI_FIRMWARE_FRAMEBUFFER_SET_BACKLIGHT = 0x0004800f, -From 3223d97f3ef0560bb0c7083d52e99643d9690d26 Mon Sep 17 00:00:00 2001 +From e164ee9987147c29263b184bb8358a357003b7e8 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 20 Feb 2017 17:01:21 +0000 -Subject: [PATCH 088/199] bcm2835-gpio-exp: Driver for GPIO expander via +Subject: [PATCH 094/129] bcm2835-gpio-exp: Driver for GPIO expander via mailbox service Pi3 and Compute Module 3 have a GPIO expander that the @@ -108460,10 +110588,10 @@ index 5f34e1257117fb48013c9926a8a223d64a598ab7..c819c21b0158a59c1308882e5a40e3f3 /* Dispmanx TAGS */ RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE = 0x00040001, -From 5d42ed1697d9f6fdb7637cdde6f46c16eacb20d0 Mon Sep 17 00:00:00 2001 +From 9e5f33653205607cacd13a7666eccece3a7d6da4 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Tue, 23 Feb 2016 17:26:48 +0000 -Subject: [PATCH 089/199] amba_pl011: Don't use DT aliases for numbering +Subject: [PATCH 095/129] amba_pl011: Don't use DT aliases for numbering The pl011 driver looks for DT aliases of the form "serial", and if found uses as the device ID. This can cause @@ -108492,10 +110620,10 @@ index 1888d168a41c87c605962da2605df8ab1c02bd20..e22b9e79836a6aeef4c8f9fb618b9595 uap->old_cr = 0; uap->port.dev = dev; -From d7f2ab8caad1d23361e64cdad22225642052c44d Mon Sep 17 00:00:00 2001 +From 6fe7c9b534c7e1aa0cb75d47b27a2f85e7b17aae Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Wed, 1 Mar 2017 16:07:39 +0000 -Subject: [PATCH 090/199] amba_pl011: Round input clock up +Subject: [PATCH 096/129] amba_pl011: Round input clock up The UART clock is initialised to be as close to the requested frequency as possible without exceeding it. Now that there is a @@ -108581,10 +110709,10 @@ index e22b9e79836a6aeef4c8f9fb618b9595c551500f..4b815abbf9913075885ee60f4d9ad49d /* unregisters the driver also if no more ports are left */ static void pl011_unregister_port(struct uart_amba_port *uap) -From 7b6a45cb774c63411740d790044367d1749f97ff Mon Sep 17 00:00:00 2001 +From 768c90f10d2587bd8abc735114c7c853b70310f4 Mon Sep 17 00:00:00 2001 From: Pantelis Antoniou Date: Wed, 3 Dec 2014 13:23:28 +0200 -Subject: [PATCH 091/199] OF: DT-Overlay configfs interface +Subject: [PATCH 097/129] OF: DT-Overlay configfs interface This is a port of Pantelis Antoniou's v3 port that makes use of the new upstreamed configfs support for binary attributes. @@ -109016,10 +111144,10 @@ index 0000000000000000000000000000000000000000..0037e6868a6cda8706c88194c6a4454b +} +late_initcall(of_cfs_init); -From 69ececf62d3dd363cb121a2e8b128e1d1df21298 Mon Sep 17 00:00:00 2001 +From 1540430c40bd65a02de5063f24aaeb908256af91 Mon Sep 17 00:00:00 2001 From: Cheong2K Date: Fri, 26 Feb 2016 18:20:10 +0800 -Subject: [PATCH 092/199] brcm: adds support for BCM43341 wifi +Subject: [PATCH 098/129] brcm: adds support for BCM43341 wifi brcmfmac: Disable power management @@ -109151,10 +111279,10 @@ index f3556122c6ace17c419e13023057861957a507fa..f8d4647016a1cde3d51dd43da07a46ce BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43362_CHIP_ID, 0xFFFFFFFE, 43362), BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4339_CHIP_ID, 0xFFFFFFFF, 4339), -From 5461c6c71453f7674228ec60d38a3a181adc3964 Mon Sep 17 00:00:00 2001 +From 44f82d3decd6bab4e5b05ecb8450bc62affea3a9 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Fri, 17 Feb 2017 15:26:13 +0000 -Subject: [PATCH 093/199] brcmfmac: Mute expected startup 'errors' +Subject: [PATCH 099/129] brcmfmac: Mute expected startup 'errors' The brcmfmac WiFi driver always complains about the '00' country code. Modify the driver to ignore '00' silently. @@ -109178,10 +111306,10 @@ index 508cab2d0817914d454958f92167d350c74d9a5d..987b1f5b999b0ecb68b6ce741b8e3ddb req->alpha2[0], req->alpha2[1]); return; -From 443f7e71126f42b5033f3236d20c03cf1f51b65a Mon Sep 17 00:00:00 2001 +From 19e8cd50ec3a94a2e12bdc46e58b24f9358dfaf0 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 17 Dec 2015 13:37:07 +0000 -Subject: [PATCH 094/199] hci_h5: Don't send conf_req when ACTIVE +Subject: [PATCH 100/129] hci_h5: Don't send conf_req when ACTIVE Without this patch, a modem and kernel can continuously bombard each other with conf_req and conf_rsp messages, in a demented game of tag. @@ -109204,24 +111332,24 @@ index c0e4e26dc30d7c3c6a771b7b86df88c8cf763646..7308287259eedcaf229f8a496a0e3826 if (H5_HDR_LEN(hdr) > 2) h5->tx_win = (data[2] & 0x07); -From a889c72dbee32229a53ee87a5730c640b8deab30 Mon Sep 17 00:00:00 2001 +From c3bd471961998f57775043a1fd1bd98748eaaa58 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Mon, 13 Apr 2015 17:16:29 +0100 -Subject: [PATCH 095/199] config: Add default configs +Subject: [PATCH 101/129] config: Add default configs --- - arch/arm/configs/bcm2709_defconfig | 1312 +++++++++++++++++++++++++++++++++++ - arch/arm/configs/bcmrpi_defconfig | 1318 ++++++++++++++++++++++++++++++++++++ - 2 files changed, 2630 insertions(+) + arch/arm/configs/bcm2709_defconfig | 1326 +++++++++++++++++++++++++++++++++++ + arch/arm/configs/bcmrpi_defconfig | 1331 ++++++++++++++++++++++++++++++++++++ + 2 files changed, 2657 insertions(+) create mode 100644 arch/arm/configs/bcm2709_defconfig create mode 100644 arch/arm/configs/bcmrpi_defconfig diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig new file mode 100644 -index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf4b895a20 +index 0000000000000000000000000000000000000000..62909413e1d625a1d33559d965ee8707ca57ba91 --- /dev/null +++ b/arch/arm/configs/bcm2709_defconfig -@@ -0,0 +1,1312 @@ +@@ -0,0 +1,1326 @@ +CONFIG_LOCALVERSION="-v7" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_SYSVIPC=y @@ -109327,9 +111455,11 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_TCP_CONG_BBR=m +CONFIG_IPV6=m +CONFIG_IPV6_ROUTER_PREF=y ++CONFIG_IPV6_ROUTE_INFO=y +CONFIG_INET6_AH=m +CONFIG_INET6_ESP=m +CONFIG_INET6_IPCOMP=m ++CONFIG_IPV6_SIT_6RD=y +CONFIG_IPV6_TUNNEL=m +CONFIG_IPV6_MULTIPLE_TABLES=y +CONFIG_IPV6_SUBTREES=y @@ -109584,6 +111714,7 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_CAN_VCAN=m +CONFIG_CAN_SLCAN=m +CONFIG_CAN_MCP251X=m ++CONFIG_CAN_GS_USB=m +CONFIG_IRDA=m +CONFIG_IRLAN=m +CONFIG_IRNET=m @@ -109789,6 +111920,7 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_INPUT_TOUCHSCREEN=y +CONFIG_TOUCHSCREEN_ADS7846=m +CONFIG_TOUCHSCREEN_EGALAX=m ++CONFIG_TOUCHSCREEN_GOODIX=m +CONFIG_TOUCHSCREEN_EDT_FT5X06=m +CONFIG_TOUCHSCREEN_RPI_FT5406=m +CONFIG_TOUCHSCREEN_USB_COMPOSITE=m @@ -109838,6 +111970,7 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_I2C_BCM2708=m +CONFIG_I2C_BCM2835=m +CONFIG_I2C_GPIO=m ++CONFIG_I2C_ROBOTFUZZ_OSIF=m +CONFIG_SPI=y +CONFIG_SPI_BCM2835=m +CONFIG_SPI_BCM2835AUX=m @@ -109873,11 +112006,13 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_POWER_RESET_GPIO=y +CONFIG_BATTERY_DS2760=m +CONFIG_HWMON=m ++CONFIG_SENSORS_JC42=m +CONFIG_SENSORS_LM75=m +CONFIG_SENSORS_SHT21=m +CONFIG_SENSORS_SHTC1=m +CONFIG_SENSORS_ADS1015=m +CONFIG_SENSORS_INA2XX=m ++CONFIG_SENSORS_TMP102=m +CONFIG_THERMAL=y +CONFIG_BCM2835_THERMAL=y +CONFIG_WATCHDOG=y @@ -109889,6 +112024,8 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_MFD_WM5102=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=m ++CONFIG_REGULATOR_ARIZONA_LDO1=m ++CONFIG_REGULATOR_ARIZONA_MICSUPP=m +CONFIG_MEDIA_SUPPORT=m +CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_MEDIA_ANALOG_TV_SUPPORT=y @@ -110107,13 +112244,16 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC=m +CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS=m +CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC=m ++CONFIG_SND_BCM2708_SOC_ALLO_DIGIONE=m +CONFIG_SND_BCM2708_SOC_FE_PI_AUDIO=m +CONFIG_SND_PISOUND=m +CONFIG_SND_SOC_ADAU1701=m +CONFIG_SND_SOC_ADAU7002=m +CONFIG_SND_SOC_AK4554=m ++CONFIG_SND_SOC_SPDIF=m +CONFIG_SND_SOC_WM8804_I2C=m +CONFIG_SND_SIMPLE_CARD=m ++CONFIG_HID_BATTERY_STRENGTH=y +CONFIG_HIDRAW=y +CONFIG_UHID=m +CONFIG_HID_A4TECH=m @@ -110156,6 +112296,7 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_HID_ROCCAT=m +CONFIG_HID_SAMSUNG=m +CONFIG_HID_SONY=m ++CONFIG_SONY_FF=y +CONFIG_HID_SPEEDLINK=m +CONFIG_HID_SUNPLUS=m +CONFIG_HID_GREENASIA=m @@ -110361,6 +112502,7 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_FB_TFT_SSD1331=m +CONFIG_FB_TFT_SSD1351=m +CONFIG_FB_TFT_ST7735R=m ++CONFIG_FB_TFT_ST7789V=m +CONFIG_FB_TFT_TINYLCD=m +CONFIG_FB_TFT_TLS8204=m +CONFIG_FB_TFT_UC1701=m @@ -110379,13 +112521,13 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_EXTCON=m +CONFIG_EXTCON_ARIZONA=m +CONFIG_IIO=m -+CONFIG_IIO_BUFFER=y +CONFIG_IIO_BUFFER_CB=m -+CONFIG_IIO_KFIFO_BUF=m +CONFIG_MCP320X=m +CONFIG_MCP3422=m +CONFIG_DHT11=m +CONFIG_HTU21=m ++CONFIG_INV_MPU6050_I2C=m ++CONFIG_BMP280=m +CONFIG_PWM_BCM2835=m +CONFIG_PWM_PCA9685=m +CONFIG_RASPBERRYPI_FIRMWARE=y @@ -110536,10 +112678,10 @@ index 0000000000000000000000000000000000000000..93cdfa4ce3e7d3ff9f437a05a9ee6bcf +CONFIG_LIBCRC32C=y diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig new file mode 100644 -index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5b4994f6e +index 0000000000000000000000000000000000000000..e0dd8723047ff488e81a03ef42fdbc68c43dc721 --- /dev/null +++ b/arch/arm/configs/bcmrpi_defconfig -@@ -0,0 +1,1318 @@ +@@ -0,0 +1,1331 @@ +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_SYSVIPC=y +CONFIG_POSIX_MQUEUE=y @@ -110640,9 +112782,11 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_TCP_CONG_BBR=m +CONFIG_IPV6=m +CONFIG_IPV6_ROUTER_PREF=y ++CONFIG_IPV6_ROUTE_INFO=y +CONFIG_INET6_AH=m +CONFIG_INET6_ESP=m +CONFIG_INET6_IPCOMP=m ++CONFIG_IPV6_SIT_6RD=y +CONFIG_IPV6_TUNNEL=m +CONFIG_IPV6_MULTIPLE_TABLES=y +CONFIG_IPV6_SUBTREES=y @@ -110897,6 +113041,7 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_CAN_VCAN=m +CONFIG_CAN_SLCAN=m +CONFIG_CAN_MCP251X=m ++CONFIG_CAN_GS_USB=m +CONFIG_IRDA=m +CONFIG_IRLAN=m +CONFIG_IRNET=m @@ -111102,8 +113247,8 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_INPUT_TOUCHSCREEN=y +CONFIG_TOUCHSCREEN_ADS7846=m +CONFIG_TOUCHSCREEN_EGALAX=m -+CONFIG_TOUCHSCREEN_EDT_FT5X06=m +CONFIG_TOUCHSCREEN_GOODIX=m ++CONFIG_TOUCHSCREEN_EDT_FT5X06=m +CONFIG_TOUCHSCREEN_RPI_FT5406=m +CONFIG_TOUCHSCREEN_USB_COMPOSITE=m +CONFIG_TOUCHSCREEN_STMPE=m @@ -111152,6 +113297,7 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_I2C_BCM2708=m +CONFIG_I2C_BCM2835=m +CONFIG_I2C_GPIO=m ++CONFIG_I2C_ROBOTFUZZ_OSIF=m +CONFIG_SPI=y +CONFIG_SPI_BCM2835=m +CONFIG_SPI_BCM2835AUX=m @@ -111185,11 +113331,13 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_POWER_RESET_GPIO=y +CONFIG_BATTERY_DS2760=m +CONFIG_HWMON=m ++CONFIG_SENSORS_JC42=m +CONFIG_SENSORS_LM75=m +CONFIG_SENSORS_SHT21=m +CONFIG_SENSORS_SHTC1=m +CONFIG_SENSORS_ADS1015=m +CONFIG_SENSORS_INA2XX=m ++CONFIG_SENSORS_TMP102=m +CONFIG_THERMAL=y +CONFIG_BCM2835_THERMAL=y +CONFIG_WATCHDOG=y @@ -111201,6 +113349,8 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_MFD_WM5102=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=m ++CONFIG_REGULATOR_ARIZONA_LDO1=m ++CONFIG_REGULATOR_ARIZONA_MICSUPP=m +CONFIG_MEDIA_SUPPORT=m +CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_MEDIA_ANALOG_TV_SUPPORT=y @@ -111419,13 +113569,16 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC=m +CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS=m +CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC=m ++CONFIG_SND_BCM2708_SOC_ALLO_DIGIONE=m +CONFIG_SND_BCM2708_SOC_FE_PI_AUDIO=m +CONFIG_SND_PISOUND=m +CONFIG_SND_SOC_ADAU1701=m +CONFIG_SND_SOC_ADAU7002=m +CONFIG_SND_SOC_AK4554=m ++CONFIG_SND_SOC_SPDIF=m +CONFIG_SND_SOC_WM8804_I2C=m +CONFIG_SND_SIMPLE_CARD=m ++CONFIG_HID_BATTERY_STRENGTH=y +CONFIG_HIDRAW=y +CONFIG_UHID=m +CONFIG_HID_A4TECH=m @@ -111468,6 +113621,7 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_HID_ROCCAT=m +CONFIG_HID_SAMSUNG=m +CONFIG_HID_SONY=m ++CONFIG_SONY_FF=y +CONFIG_HID_SPEEDLINK=m +CONFIG_HID_SUNPLUS=m +CONFIG_HID_GREENASIA=m @@ -111686,6 +113840,7 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_FB_TFT_SSD1331=m +CONFIG_FB_TFT_SSD1351=m +CONFIG_FB_TFT_ST7735R=m ++CONFIG_FB_TFT_ST7789V=m +CONFIG_FB_TFT_TINYLCD=m +CONFIG_FB_TFT_TLS8204=m +CONFIG_FB_TFT_UC1701=m @@ -111704,13 +113859,13 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_EXTCON=m +CONFIG_EXTCON_ARIZONA=m +CONFIG_IIO=m -+CONFIG_IIO_BUFFER=y +CONFIG_IIO_BUFFER_CB=m -+CONFIG_IIO_KFIFO_BUF=m +CONFIG_MCP320X=m +CONFIG_MCP3422=m +CONFIG_DHT11=m +CONFIG_HTU21=m ++CONFIG_INV_MPU6050_I2C=m ++CONFIG_BMP280=m +CONFIG_PWM_BCM2835=m +CONFIG_PWM_PCA9685=m +CONFIG_RASPBERRYPI_FIRMWARE=y @@ -111859,10 +114014,10 @@ index 0000000000000000000000000000000000000000..29fd2abc2cbfcaed37cb630b5edffaa5 +CONFIG_CRC_ITU_T=y +CONFIG_LIBCRC32C=y -From 0c614d6ba3bdf1fade22f4f18c3a55654a73f023 Mon Sep 17 00:00:00 2001 +From 6d6fd6d9179c237acb740832880f1603e019e2cd Mon Sep 17 00:00:00 2001 From: Michael Zoran Date: Wed, 24 Aug 2016 03:35:56 -0700 -Subject: [PATCH 096/199] Add arm64 configuration and device tree differences. +Subject: [PATCH 102/129] Add arm64 configuration and device tree differences. Disable MMC_BCM2835_SDHOST and MMC_BCM2835 since these drivers are crashing at the moment. @@ -113276,10 +115431,10 @@ index 0000000000000000000000000000000000000000..e6b09fafa27eed2b762e3d53b55041f7 +CONFIG_LIBCRC32C=y +CONFIG_BCM2835_VCHIQ=n -From 8a91e5edc927197cf1630416ec6dcc2f8f415840 Mon Sep 17 00:00:00 2001 +From e9c43898ea8dd00edb15de87acca6c1c63048f1c Mon Sep 17 00:00:00 2001 From: Electron752 Date: Thu, 12 Jan 2017 07:07:08 -0800 -Subject: [PATCH 097/199] ARM64: Make it work again on 4.9 (#1790) +Subject: [PATCH 103/129] ARM64: Make it work again on 4.9 (#1790) * Invoke the dtc compiler with the same options used in arm mode. * ARM64 now uses the bcm2835 platform just like ARM32. @@ -113288,10 +115443,10 @@ Subject: [PATCH 097/199] ARM64: Make it work again on 4.9 (#1790) Signed-off-by: Michael Zoran --- arch/arm64/Kconfig.platforms | 28 -------- - arch/arm64/boot/dts/broadcom/Makefile | 9 +++ + arch/arm64/boot/dts/broadcom/Makefile | 11 ++- arch/arm64/boot/dts/overlays | 1 + arch/arm64/configs/bcmrpi3_defconfig | 125 +++++++++++----------------------- - 4 files changed, 48 insertions(+), 115 deletions(-) + 4 files changed, 49 insertions(+), 116 deletions(-) create mode 120000 arch/arm64/boot/dts/overlays diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms @@ -113333,10 +115488,10 @@ index d8550598e3403e7d35050e48e71bac17ed8dc493..1b7f6ea1171f5cc7a1df649d146520c1 bool "Allwinner sunxi 64-bit SoC Family" select ARCH_HAS_RESET_CONTROLLER diff --git a/arch/arm64/boot/dts/broadcom/Makefile b/arch/arm64/boot/dts/broadcom/Makefile -index 1046bed8bf1509eaf3127733b9263fa39a166895..97af2ececc52ca3aad7b84dc2fdb5c269a45bde0 100644 +index 1046bed8bf1509eaf3127733b9263fa39a166895..3b76320112196a1fce7a0941c696fd1ec43b817f 100644 --- a/arch/arm64/boot/dts/broadcom/Makefile +++ b/arch/arm64/boot/dts/broadcom/Makefile -@@ -1,6 +1,15 @@ +@@ -1,8 +1,17 @@ +# Enable fixups to support overlays on BCM2835 platforms + +ifeq ($(CONFIG_ARCH_BCM2835),y) @@ -113350,8 +115505,11 @@ index 1046bed8bf1509eaf3127733b9263fa39a166895..97af2ececc52ca3aad7b84dc2fdb5c26 + +dts-dirs += ../overlays - dts-dirs := stingray +-dts-dirs := stingray ++dts-dirs += stingray always := $(dtb-y) + subdir-y := $(dts-dirs) + clean-files := *.dtb diff --git a/arch/arm64/boot/dts/overlays b/arch/arm64/boot/dts/overlays new file mode 120000 index 0000000000000000000000000000000000000000..ded08646b6f66cdf734f8bf9c1be3a2e3a7103d7 @@ -113688,10 +115846,10 @@ index e6b09fafa27eed2b762e3d53b55041f793683d27..c7e891d72969a388d9b135a36dbfc9c9 CONFIG_LIBCRC32C=y -CONFIG_BCM2835_VCHIQ=n -From ba699d70dc35ab69b559362ee0f3ab72eafc5824 Mon Sep 17 00:00:00 2001 +From fb47b55bed10e44abfe8e21cf6a8d3bf75e54200 Mon Sep 17 00:00:00 2001 From: Michael Zoran Date: Thu, 12 Jan 2017 19:10:07 -0800 -Subject: [PATCH 098/199] ARM64: Enable HDMI audio and vc04_services in +Subject: [PATCH 104/129] ARM64: Enable HDMI audio and vc04_services in bcmrpi3_defconfig Signed-off-by: Michael Zoran @@ -113720,10 +115878,10 @@ index c7e891d72969a388d9b135a36dbfc9c9cb609bf8..4b90f9b64abe9f089ba56b13d5a00de3 CONFIG_BCM2835_MBOX=y # CONFIG_IOMMU_SUPPORT is not set -From 4745f7114e0a766c19b60c8dbb75290fc9793532 Mon Sep 17 00:00:00 2001 +From 900935e9cd0fd44dc9f8636308c8c7b421a8c83a Mon Sep 17 00:00:00 2001 From: Michael Zoran Date: Thu, 12 Jan 2017 19:14:03 -0800 -Subject: [PATCH 099/199] ARM64: Run bcmrpi3_defconfig through savedefconfig. +Subject: [PATCH 105/129] ARM64: Run bcmrpi3_defconfig through savedefconfig. Signed-off-by: Michael Zoran --- @@ -113768,10 +115926,10 @@ index 4b90f9b64abe9f089ba56b13d5a00de33343bfb9..dac962ca1634662ce7d966f1ffb53b5b CONFIG_FB_TFT_AGM1264K_FL=m CONFIG_FB_TFT_BD663474=m -From b1073189a8a4587bc0fc366ca84167202c8d5611 Mon Sep 17 00:00:00 2001 +From ef2764a77908404cd53995df24b1dc7fc66824cd Mon Sep 17 00:00:00 2001 From: Electron752 Date: Sat, 14 Jan 2017 02:54:26 -0800 -Subject: [PATCH 100/199] ARM64: Enable Kernel Address Space Randomization +Subject: [PATCH 106/129] ARM64: Enable Kernel Address Space Randomization (#1792) Randomization allows the mapping between virtual addresses and physical @@ -113803,10 +115961,10 @@ index dac962ca1634662ce7d966f1ffb53b5bfa27c506..aae33b4b3c3e736ea7cd3ca242158ad6 CONFIG_BINFMT_MISC=y CONFIG_COMPAT=y -From 4f9ae4d4070553f3600c1017add373cf60aa03b6 Mon Sep 17 00:00:00 2001 +From fe858fcdd237aca3425f4020862fc06a10ca12de Mon Sep 17 00:00:00 2001 From: Michael Zoran Date: Sun, 15 Jan 2017 07:31:59 -0800 -Subject: [PATCH 101/199] ARM64: Enable RTL8187/RTL8192CU wifi in build config +Subject: [PATCH 107/129] ARM64: Enable RTL8187/RTL8192CU wifi in build config These drivers build now, so they can be enabled back in the build configuration just like they are for @@ -113831,10 +115989,10 @@ index aae33b4b3c3e736ea7cd3ca242158ad6ba558aff..b7d762df19b85e369a32cd823dfd0621 CONFIG_ZD1211RW=m CONFIG_MAC80211_HWSIM=m -From 22b662614fdf0110e08c561af08eb01e20f90bb7 Mon Sep 17 00:00:00 2001 +From f4fca0f5426c2745774afa536c2c4fc9aca8d9c8 Mon Sep 17 00:00:00 2001 From: Michael Zoran Date: Sat, 14 Jan 2017 21:33:51 -0800 -Subject: [PATCH 102/199] ARM64/DWC_OTG: Port dwc_otg driver to ARM64 +Subject: [PATCH 108/129] ARM64/DWC_OTG: Port dwc_otg driver to ARM64 In ARM64, the FIQ mechanism used by this driver is not current implemented. As a workaround, reqular IRQ is used instead @@ -113891,7 +116049,7 @@ index e7bdd12015fee1727a7956ae3e3b2786e88892c1..4872b8113b68bc9087cf5e128657c580 dwc_otg-objs += dwc_otg_cfi.o endif diff --git a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c -index 2035e0762dc6d60673c8fbc47a90b72254f50b69..208252645c09d1d17bf07673989f91b7f4b3ef7a 100644 +index b7731e7edb4602f93f028d786194822161bbf0f8..0163e9cf620ba58df36a872b82cea92734baada6 100644 --- a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c +++ b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c @@ -74,6 +74,21 @@ void notrace _fiq_print(enum fiq_debug_level dbg_lvl, volatile struct fiq_state @@ -113926,7 +116084,7 @@ index 2035e0762dc6d60673c8fbc47a90b72254f50b69..208252645c09d1d17bf07673989f91b7 * fiq_fsm_restart_channel() - Poke channel enable bit for a split transaction * @channel: channel to re-enable diff --git a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h -index f9fddfbcffb37f32c808fd78f222b676378398b1..0a1ddf3f89f45ca75b8880722fbc22cbdc9f4a2f 100644 +index 8340041ce65665c094e2ad49fd5e8eb1751506f3..ed088f34f210e9a337ab9b80fff0cf9e9b0241ea 100644 --- a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h +++ b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h @@ -127,6 +127,12 @@ enum fiq_debug_level { @@ -113951,7 +116109,7 @@ index f9fddfbcffb37f32c808fd78f222b676378398b1..0a1ddf3f89f45ca75b8880722fbc22cb struct fiq_state; extern void _fiq_print (enum fiq_debug_level dbg_lvl, volatile struct fiq_state *state, char *fmt, ...); -@@ -355,6 +363,22 @@ struct fiq_state { +@@ -357,6 +365,22 @@ struct fiq_state { struct fiq_channel_state channel[0]; }; @@ -113975,10 +116133,10 @@ index f9fddfbcffb37f32c808fd78f222b676378398b1..0a1ddf3f89f45ca75b8880722fbc22cb extern void fiq_fsm_spin_unlock(fiq_lock_t *lock); diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -index 5e4d4ffe7966486d40a5b5e2423ac4df0de772a8..a2dc6337836b2719f4c954edeeb2a71301931b04 100644 +index 60464acab588a1e189f39b268ffc25766c13dc85..7710370b30363e3170bf9bf522597c5f41dfb908 100644 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -@@ -1002,6 +1002,10 @@ int dwc_otg_hcd_init(dwc_otg_hcd_t * hcd, dwc_otg_core_if_t * core_if) +@@ -1000,6 +1000,10 @@ int dwc_otg_hcd_init(dwc_otg_hcd_t * hcd, dwc_otg_core_if_t * core_if) } DWC_MEMSET(hcd->fiq_state, 0, (sizeof(struct fiq_state) + (sizeof(struct fiq_channel_state) * num_channels))); @@ -114006,7 +116164,7 @@ index fb57db09378f4ab95d57cb58aa570a915ccb61c3..a384db5e7ac219936ace65e5616e68c8 /** * Returns private data set by diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c -index fc52495e4749f45dcf270c1c22960f163b6dc86d..a4355afc77b68718fdaba6c5d4be257dadc75036 100644 +index ed855eb9c3b64d54e93c5aa7e06212e779400dfd..c8f52709a7d24974c0a38dcf1708f91073e96b0e 100644 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c @@ -36,8 +36,9 @@ @@ -114177,10 +116335,10 @@ index 6b2c7d0c93f36a63863ff4b0ecc1f3eab77e058b..d7b700ff17821ad1944e36721fe6b2db /** The OS page size */ #define DWC_OS_PAGE_SIZE PAGE_SIZE -From 084d9b5892b4378a088e96823e46050efc59f102 Mon Sep 17 00:00:00 2001 +From 167c98d704c7a38aeab88f5005077d4bdc3fcac9 Mon Sep 17 00:00:00 2001 From: Michael Zoran Date: Sat, 14 Jan 2017 21:43:57 -0800 -Subject: [PATCH 103/199] ARM64: Round-Robin dispatch IRQs between CPUs. +Subject: [PATCH 109/129] ARM64: Round-Robin dispatch IRQs between CPUs. IRQ-CPU mapping is round robined on ARM64 to increase concurrency and allow multiple interrupts to be serviced @@ -114222,7 +116380,7 @@ index 8ed457fd74bd23bee27b64a2c9e3828ce0e4fb87..a035e1ceacc0494fa293e6811ff8f7e3 static int armctrl_xlate(struct irq_domain *d, struct device_node *ctrlr, diff --git a/drivers/irqchip/irq-bcm2836.c b/drivers/irqchip/irq-bcm2836.c -index c4e151451cf8c8ebde5225515eac2786d6f61d46..9a7ee04ee0d9b7aa734cf3159ed59c19a338de0d 100644 +index bee4d2d2ebacc3233423bb9d825e076b9f52fccd..014f13f89eb896f5cfc75ed9891787d0490baa4b 100644 --- a/drivers/irqchip/irq-bcm2836.c +++ b/drivers/irqchip/irq-bcm2836.c @@ -145,6 +145,27 @@ static void bcm2836_arm_irqchip_unmask_gpu_irq(struct irq_data *d) @@ -114254,10 +116412,10 @@ index c4e151451cf8c8ebde5225515eac2786d6f61d46..9a7ee04ee0d9b7aa734cf3159ed59c19 .name = "bcm2836-gpu", .irq_mask = bcm2836_arm_irqchip_mask_gpu_irq, -From e8c95b8b02b65eb5c3dbbea55415133d36014b7e Mon Sep 17 00:00:00 2001 +From 3d387f3c82eb55430bceb4a21b3150e80a7a5a00 Mon Sep 17 00:00:00 2001 From: Michael Zoran Date: Sat, 14 Jan 2017 21:45:03 -0800 -Subject: [PATCH 104/199] ARM64: Enable DWC_OTG Driver In ARM64 Build +Subject: [PATCH 110/129] ARM64: Enable DWC_OTG Driver In ARM64 Build Config(bcmrpi3_defconfig) Signed-off-by: Michael Zoran @@ -114278,10 +116436,10 @@ index b7d762df19b85e369a32cd823dfd062145bdefa7..4d85c231c5ea0244e1b05fb4a5e3c8fd CONFIG_USB_STORAGE=y CONFIG_USB_STORAGE_REALTEK=m -From 48468a21e50ad4bed91d82f8d003b23eb503b43e Mon Sep 17 00:00:00 2001 +From d340cd7493c6124278913e0e0bd1bcd00153f124 Mon Sep 17 00:00:00 2001 From: Michael Zoran Date: Sat, 11 Feb 2017 01:18:31 -0800 -Subject: [PATCH 105/199] ARM64: Force hardware emulation of deprecated +Subject: [PATCH 111/129] ARM64: Force hardware emulation of deprecated instructions. --- @@ -114309,10 +116467,10 @@ index f0e6d717885b1fcf3b22f64c10c38f19c25f809d..0cb830d30fb6d2bd26ab572efe893649 case INSN_OBSOLETE: insn->current_mode = INSN_UNDEF; -From e25377a56bf44f29cd8c1f0ce8cabb672c6957a8 Mon Sep 17 00:00:00 2001 +From 4a4a6c4967fe59a4d24117939af272d3b4cc8712 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 10 Feb 2017 17:57:08 -0800 -Subject: [PATCH 106/199] build/arm64: Add rules for .dtbo files for dts +Subject: [PATCH 112/129] build/arm64: Add rules for .dtbo files for dts overlays We now create overlays as .dtbo files. @@ -114337,51 +116495,41 @@ index 9b41f1e3b1a039cd45fe842e10abff0181186fdf..dc2859b8eed168ed52e95c503e7a5ce3 dtbs: prepare scripts -From 6e4e26e2dad7cb32b71d00df6352d553c54d517a Mon Sep 17 00:00:00 2001 -From: Eric Anholt -Date: Mon, 9 May 2016 17:28:18 -0700 -Subject: [PATCH 107/199] clk: bcm2835: Mark GPIO clocks enabled at boot as - critical. +From cd741e0be1011d9e7c167cde89efb09f97648c00 Mon Sep 17 00:00:00 2001 +From: Bilal Amarni +Date: Wed, 24 May 2017 10:52:50 +0200 +Subject: [PATCH 113/129] enable drivers for GPIO expander and vcio -These divide off of PLLD_PER and are used for the ethernet and wifi -PHYs source PLLs. Neither of them is currently represented by a phy -device that would grab the clock for us. - -This keeps other drivers from killing the networking PHYs when they -disable their own clocks and trigger PLLD_PER's refcount going to 0. - -v2: Skip marking as critical if they aren't on at boot. - -Signed-off-by: Eric Anholt --- - drivers/clk/bcm/clk-bcm2835.c | 9 +++++++++ - 1 file changed, 9 insertions(+) + arch/arm64/configs/bcmrpi3_defconfig | 3 +++ + 1 file changed, 3 insertions(+) -diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c -index 336f8c9c44325d0a94e591a8557f7af246adc857..caa05e5ad0b7b5cd683e04fb3591a3dfcb40823f 100644 ---- a/drivers/clk/bcm/clk-bcm2835.c -+++ b/drivers/clk/bcm/clk-bcm2835.c -@@ -1484,6 +1484,15 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, - init.flags = data->flags | CLK_IGNORE_UNUSED; - - /* -+ * Some GPIO clocks for ethernet/wifi PLLs are marked as -+ * critical (since some platforms use them), but if the -+ * firmware didn't have them turned on then they clearly -+ * aren't actually critical. -+ */ -+ if ((cprman_read(cprman, data->ctl_reg) & CM_ENABLE) == 0) -+ init.flags &= ~CLK_IS_CRITICAL; -+ -+ /* - * Pass the CLK_SET_RATE_PARENT flag if we are allowed to propagate - * rate changes on at least of the parents. - */ +diff --git a/arch/arm64/configs/bcmrpi3_defconfig b/arch/arm64/configs/bcmrpi3_defconfig +index 4d85c231c5ea0244e1b05fb4a5e3c8fd3e651ddf..9dcb58a519d041fadae99c81a7bda621b2a49f12 100644 +--- a/arch/arm64/configs/bcmrpi3_defconfig ++++ b/arch/arm64/configs/bcmrpi3_defconfig +@@ -575,6 +575,8 @@ CONFIG_SERIO_RAW=m + CONFIG_GAMEPORT=m + CONFIG_GAMEPORT_NS558=m + CONFIG_GAMEPORT_L4=m ++CONFIG_BRCM_CHAR_DRIVERS=y ++CONFIG_BCM_VCIO=y + # CONFIG_BCM2835_DEVGPIOMEM is not set + # CONFIG_BCM2835_SMI_DEV is not set + # CONFIG_LEGACY_PTYS is not set +@@ -609,6 +611,7 @@ CONFIG_PPS=m + CONFIG_PPS_CLIENT_LDISC=m + CONFIG_PPS_CLIENT_GPIO=m + CONFIG_GPIO_SYSFS=y ++CONFIG_GPIO_BCM_EXP=y + CONFIG_GPIO_BCM_VIRT=y + CONFIG_GPIO_ARIZONA=m + CONFIG_GPIO_STMPE=y -From 8ba1d51bc8cb9a1660ef5a16b89ece470f9a3f6a Mon Sep 17 00:00:00 2001 +From 049d05d668250c8ecd91908177fed22322a7797b Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Tue, 24 Feb 2015 13:40:50 +0000 -Subject: [PATCH 108/199] pinctrl-bcm2835: Fix interrupt handling for GPIOs +Subject: [PATCH 114/129] pinctrl-bcm2835: Fix interrupt handling for GPIOs 28-31 and 46-53 Contrary to the documentation, the BCM2835 GPIO controller actually has @@ -114414,38 +116562,10 @@ index a9d480df32562defbf8be0faf0a39bfe06ff71f9..18c92bae3b2e7e9f8208ca0d4487b08b .suppress_bind_attrs = true, }, -From 7a1439b8ae71715ce37c8172bb02395a2195d917 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Thu, 23 Mar 2017 10:06:56 +0000 -Subject: [PATCH 109/199] ASoC: Add prompt for ICS43432 codec - -Without a prompt string, a config setting can't be included in a -defconfig. Give CONFIG_SND_SOC_ICS43432 a prompt so that Pi soundcards -can use the driver. - -Signed-off-by: Phil Elwell ---- - sound/soc/codecs/Kconfig | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig -index aca3a53f08dba8762307f7c25a5d7c5561b9cf71..a3be6e005a895b995897cc007bb85c780a42de8b 100644 ---- a/sound/soc/codecs/Kconfig -+++ b/sound/soc/codecs/Kconfig -@@ -573,7 +573,7 @@ config SND_SOC_HDAC_HDMI - select HDMI - - config SND_SOC_ICS43432 -- tristate -+ tristate "InvenSense ICS43432 I2S microphone codec" - - config SND_SOC_INNO_RK3036 - tristate "Inno codec driver for RK3036 SoC" - -From a96b3ae65e7787e3aed57728790d890d01c91280 Mon Sep 17 00:00:00 2001 +From 90aed6ca4d4698fac72196495c38bcfbc2adaaf5 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 23 Mar 2017 16:34:46 +0000 -Subject: [PATCH 110/199] bcm2835-aux: Add aux interrupt controller +Subject: [PATCH 115/129] bcm2835-aux: Add aux interrupt controller The AUX block has a shared interrupt line with a register indicating which devices have active IRQs. Expose this as a nested interrupt @@ -114609,213 +116729,10 @@ index bd750cf2238d61489811e7d7bd3b5f9950ed53c8..41e0702fae4692221980b0d02aed1ba6 BCM2835_AUX_CLOCK_COUNT, GFP_KERNEL); if (!onecell) -From 41c0b2c6f9d170b84bb010fa176d8bad683bc452 Mon Sep 17 00:00:00 2001 -From: Stefan Agner -Date: Fri, 29 Apr 2016 10:32:17 -0700 -Subject: [PATCH 111/199] mmc: read mmc alias from device tree - -To get the SD/MMC host device ID, read the alias from the device -tree. - -This is useful in case a SoC has multipe SD/MMC host controllers while -the second controller should logically be the first device (e.g. if -the second controller is connected to an internal eMMC). Combined -with block device numbering using MMC/SD host device ID, this -results in predictable name assignment of the internal eMMC block -device. - -Signed-off-by: Stefan Agner -Signed-off-by: Dmitry Torokhov -[dianders: rebase + roll in http://crosreview.com/259916] -Signed-off-by: Douglas Anderson ---- - drivers/mmc/core/host.c | 17 ++++++++++++++++- - 1 file changed, 16 insertions(+), 1 deletion(-) - -diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c -index 1503412f826cd0e0e9ad37a0554b31596a49eb77..2f5b3cf86293b96b104eac7c6d48a5839d7e974b 100644 ---- a/drivers/mmc/core/host.c -+++ b/drivers/mmc/core/host.c -@@ -344,15 +344,30 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) - { - int err; - struct mmc_host *host; -+ int id; - - host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); - if (!host) - return NULL; - -+ /* If OF aliases exist, start dynamic assignment after highest */ -+ id = of_alias_get_highest_id("mmc"); -+ id = (id < 0) ? 0 : id + 1; -+ -+ /* If this devices has OF node, maybe it has an alias */ -+ if (dev->of_node) { -+ int of_id = of_alias_get_id(dev->of_node, "mmc"); -+ -+ if (of_id < 0) -+ dev_warn(dev, "/aliases ID not available\n"); -+ else -+ id = of_id; -+ } -+ - /* scanning will be enabled when we're ready */ - host->rescan_disable = 1; - -- err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL); -+ err = ida_simple_get(&mmc_host_ida, id, 0, GFP_KERNEL); - if (err < 0) { - kfree(host); - return NULL; - -From e4a17cab1aaee3115790fd04fba8c800ef7352d2 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Wed, 11 May 2016 12:50:33 +0100 -Subject: [PATCH 112/199] mmc: Add MMC_QUIRK_ERASE_BROKEN for some cards - -Some SD cards have been found that corrupt data when small blocks -are erased. Add a quirk to indicate that ERASE should not be used, -and set it for cards of that type. - -Signed-off-by: Phil Elwell - -mmc: Apply QUIRK_BROKEN_ERASE to other capacities - -Signed-off-by: Phil Elwell - -mmc: Add card_quirks module parameter, log quirks - -Use mmc_block.card_quirks to override the quirks for all SD or MMC -cards. The value is a bitfield using the bit positions defined in -include/linux/mmc/card.h. If the module parameter is placed in the -kernel command line (or bootargs) stored on the card then, assuming the -device only has one SD card interface, the override effectively becomes -card-specific. - -Signed-off-by: Phil Elwell ---- - drivers/mmc/core/block.c | 28 +++++++++++++++++++++++++--- - drivers/mmc/core/core.c | 3 ++- - drivers/mmc/core/quirks.h | 11 +++++++++++ - include/linux/mmc/card.h | 2 ++ - 4 files changed, 40 insertions(+), 4 deletions(-) - -diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c -index 8bd7aba811e969a3b7cfdc6cf12e685f25e8c37e..cd1eb5cf73358a0104fbf4b6ed8e72dd491d658d 100644 ---- a/drivers/mmc/core/block.c -+++ b/drivers/mmc/core/block.c -@@ -125,6 +125,13 @@ static DEFINE_MUTEX(open_lock); - module_param(perdev_minors, int, 0444); - MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device"); - -+/* -+ * Allow quirks to be overridden for the current card -+ */ -+static char *card_quirks; -+module_param(card_quirks, charp, 0644); -+MODULE_PARM_DESC(card_quirks, "Force the use of the indicated quirks (a bitfield)"); -+ - static inline int mmc_blk_part_switch(struct mmc_card *card, - struct mmc_blk_data *md); - -@@ -2287,6 +2294,7 @@ static int mmc_blk_probe(struct mmc_card *card) - { - struct mmc_blk_data *md, *part_md; - char cap_str[10]; -+ char quirk_str[24]; - - /* - * Check that the card supports the command class(es) we need. -@@ -2294,7 +2302,16 @@ static int mmc_blk_probe(struct mmc_card *card) - if (!(card->csd.cmdclass & CCC_BLOCK_READ)) - return -ENODEV; - -- mmc_fixup_device(card, mmc_blk_fixups); -+ if (card_quirks) { -+ unsigned long quirks; -+ if (kstrtoul(card_quirks, 0, &quirks) == 0) -+ card->quirks = (unsigned int)quirks; -+ else -+ pr_err("mmc_block: Invalid card_quirks parameter '%s'\n", -+ card_quirks); -+ } -+ else -+ mmc_fixup_device(card, mmc_blk_fixups); - - md = mmc_blk_alloc(card); - if (IS_ERR(md)) -@@ -2302,9 +2319,14 @@ static int mmc_blk_probe(struct mmc_card *card) - - string_get_size((u64)get_capacity(md->disk), 512, STRING_UNITS_2, - cap_str, sizeof(cap_str)); -- pr_info("%s: %s %s %s %s\n", -+ if (card->quirks) -+ snprintf(quirk_str, sizeof(quirk_str), -+ " (quirks 0x%08x)", card->quirks); -+ else -+ quirk_str[0] = '\0'; -+ pr_info("%s: %s %s %s%s%s\n", - md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), -- cap_str, md->read_only ? "(ro)" : ""); -+ cap_str, md->read_only ? " (ro)" : "", quirk_str); - - if (mmc_blk_alloc_parts(card, md)) - goto out; -diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c -index 26431267a3e2d790d4eae99e65881ca60bd2047d..0ec589ace762a27f3c5ea39226fef3a67442675f 100644 ---- a/drivers/mmc/core/core.c -+++ b/drivers/mmc/core/core.c -@@ -2211,7 +2211,8 @@ EXPORT_SYMBOL(mmc_erase); - int mmc_can_erase(struct mmc_card *card) - { - if ((card->host->caps & MMC_CAP_ERASE) && -- (card->csd.cmdclass & CCC_ERASE) && card->erase_size) -+ (card->csd.cmdclass & CCC_ERASE) && card->erase_size && -+ !(card->quirks & MMC_QUIRK_ERASE_BROKEN)) - return 1; - return 0; - } -diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h -index fb725934fa21cee1b98fd7bc08227bf6d0317549..05c8d7381fff5ae88531129d9a5ddd554bddb43e 100644 ---- a/drivers/mmc/core/quirks.h -+++ b/drivers/mmc/core/quirks.h -@@ -90,6 +90,17 @@ static const struct mmc_fixup mmc_blk_fixups[] = { - MMC_FIXUP("V10016", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc, - MMC_QUIRK_TRIM_BROKEN), - -+ /* -+ * On some Kingston SD cards, multiple erases of less than 64 -+ * sectors can cause corruption. -+ */ -+ MMC_FIXUP("SD16G", 0x41, 0x3432, add_quirk_mmc, -+ MMC_QUIRK_ERASE_BROKEN), -+ MMC_FIXUP("SD32G", 0x41, 0x3432, add_quirk_mmc, -+ MMC_QUIRK_ERASE_BROKEN), -+ MMC_FIXUP("SD64G", 0x41, 0x3432, add_quirk_mmc, -+ MMC_QUIRK_ERASE_BROKEN), -+ - END_FIXUP - }; - -diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h -index 46c73e97e61f08a41d9753079345f5965caebbc5..388c551ed11e9d06ea1c25b6553d47a8d668953a 100644 ---- a/include/linux/mmc/card.h -+++ b/include/linux/mmc/card.h -@@ -269,6 +269,8 @@ struct mmc_card { - #define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */ - #define MMC_QUIRK_BROKEN_HPI (1<<13) /* Disable broken HPI support */ - -+#define MMC_QUIRK_ERASE_BROKEN (1<<31) /* Skip erase */ -+ - bool reenable_cmdq; /* Re-enable Command Queue */ - - unsigned int erase_size; /* erase size in sectors */ - -From bc8a54e265eb99330b99592b0a2697527b419a14 Mon Sep 17 00:00:00 2001 +From a2b5db64ae961375981dc9c21230e918e9da1a53 Mon Sep 17 00:00:00 2001 From: Yasunari Takiguchi Date: Fri, 14 Apr 2017 10:43:57 +0100 -Subject: [PATCH 113/199] This is the driver for Sony CXD2880 DVB-T2/T tuner + +Subject: [PATCH 116/129] This is the driver for Sony CXD2880 DVB-T2/T tuner + demodulator. It includes the CXD2880 driver and the CXD2880 SPI adapter. The current CXD2880 driver version is 1.4.1 - 1.0.1 released on April 13, 2017. @@ -130947,10 +132864,10 @@ index 0000000000000000000000000000000000000000..82e122349055be817eb74ed5bbcd7560 +MODULE_AUTHOR("Sony Semiconductor Solutions Corporation"); +MODULE_LICENSE("GPL v2"); -From 98e3c0e9fb2766ef037ebe71559f5952f328849a Mon Sep 17 00:00:00 2001 +From 8519c61633549f88e24ec126082a29c176da4253 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 14 Sep 2016 09:18:09 +0100 -Subject: [PATCH 114/199] raspberrypi-firmware: Define the MBOX channel in the +Subject: [PATCH 117/129] raspberrypi-firmware: Define the MBOX channel in the header. Signed-off-by: Eric Anholt @@ -130972,10 +132889,10 @@ index c819c21b0158a59c1308882e5a40e3f3fe73cbdf..de2a3dcd562beb752266eaf0070e5586 enum rpi_firmware_property_status { -From 2e01d3c71c50672a9fcb0b18f1abf66ed22404b8 Mon Sep 17 00:00:00 2001 +From 49686a4d16e39cbe24057dc16ec0cffb0009055f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 14 Sep 2016 09:16:19 +0100 -Subject: [PATCH 115/199] raspberrypi-firmware: Export the general transaction +Subject: [PATCH 118/129] raspberrypi-firmware: Export the general transaction function. The vc4-firmware-kms module is going to be doing the MBOX FB call. @@ -131019,10 +132936,10 @@ index de2a3dcd562beb752266eaf0070e55861d553f5f..dc7fd58afd5dddebf9b17065bb069a1d #endif /* __SOC_RASPBERRY_FIRMWARE_H__ */ -From 8504a4123116599240bd60725badc83c4124094a Mon Sep 17 00:00:00 2001 +From 89922ab276b06410d8ef5e78f370a8e13bacfe32 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 14 Sep 2016 08:39:33 +0100 -Subject: [PATCH 116/199] drm/vc4: Add a mode for using the closed firmware for +Subject: [PATCH 119/129] drm/vc4: Add a mode for using the closed firmware for display. Signed-off-by: Eric Anholt @@ -131794,10 +133711,10 @@ index 0000000000000000000000000000000000000000..7dd233eed677c1689492ab95bc864753 + }, +}; -From 8974c502145b67e125c609be2e2ce833cbac8894 Mon Sep 17 00:00:00 2001 +From 98157ac6f00edcad39580c8ee8c665a11d89ba08 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 1 Feb 2017 17:09:18 -0800 -Subject: [PATCH 117/199] drm/vc4: Name the primary and cursor planes in fkms. +Subject: [PATCH 120/129] drm/vc4: Name the primary and cursor planes in fkms. This makes debugging nicer, compared to trying to remember what the IDs are. @@ -131821,10 +133738,10 @@ index 7dd233eed677c1689492ab95bc86475330d2d63b..e6097046fb25361bc61d657083d95b63 if (type == DRM_PLANE_TYPE_PRIMARY) { vc4_plane->fbinfo = -From 6aecce4695f3c447cee0fd40286a0a5cbf90a757 Mon Sep 17 00:00:00 2001 +From de225be7df4dcaad443716baf7c4249109adcc0f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 1 Feb 2017 17:10:09 -0800 -Subject: [PATCH 118/199] drm/vc4: Add DRM_DEBUG_ATOMIC for the insides of +Subject: [PATCH 121/129] drm/vc4: Add DRM_DEBUG_ATOMIC for the insides of fkms. Trying to debug weston on fkms involved figuring out what calls I was @@ -131894,10 +133811,10 @@ index e6097046fb25361bc61d657083d95b634232aabc..72d0b9cffe3d2997d69040c46f4aee11 RPI_FIRMWARE_SET_CURSOR_STATE, &packet_state, -From f7634a508d916ee80c2c5e13efe3bd0c8a150e01 Mon Sep 17 00:00:00 2001 +From f2e9a1b05c7e626085cf93930263e0e9b9154877 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 2 Feb 2017 09:42:18 -0800 -Subject: [PATCH 119/199] drm/vc4: Fix sending of page flip completion events +Subject: [PATCH 122/129] drm/vc4: Fix sending of page flip completion events in FKMS mode. In the rewrite of vc4_crtc.c for fkms, I dropped the part of the @@ -131939,10 +133856,10 @@ index 72d0b9cffe3d2997d69040c46f4aee11e22aa213..185f9bd3c1b2d47d0c1fc5293db4199b static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc) -From 6f85a018909173940a13cc4c9f64ae9c247d2e6d Mon Sep 17 00:00:00 2001 +From caeeb7fd92cb6b7225ecf470191983090d4c6ad1 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Tue, 18 Apr 2017 21:43:46 +0100 -Subject: [PATCH 120/199] vc4_fkms: Apply firmware overscan offset to hardware +Subject: [PATCH 123/129] vc4_fkms: Apply firmware overscan offset to hardware cursor --- @@ -131999,1031 +133916,10 @@ index 185f9bd3c1b2d47d0c1fc5293db4199bd8963023..072f377b7423ee603d73ace2bf6d620f return 0; -From ef1fd13268221caf2cf997ee3d66bb5d7b04201e Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Tue, 16 May 2017 14:39:49 +0100 -Subject: [PATCH 121/199] mmc: Change downstream MMC driver CONFIG option - -The upstream SDHOST driver has now claimed CONFIG_MMC_BCM2835, which -clashes with the downstream MMC driver. Rename the downstream option to -CONFIG_MMC_BCM2835_MMC. - -Signed-off-by: Phil Elwell ---- - drivers/mmc/host/Kconfig | 4 ++-- - drivers/mmc/host/Makefile | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig -index 64bd7825131d3dcb003e7ece581b8d599a717b31..d47cce77c0551d78fa51f50e2c8086f26c7b9e56 100644 ---- a/drivers/mmc/host/Kconfig -+++ b/drivers/mmc/host/Kconfig -@@ -4,7 +4,7 @@ - - comment "MMC/SD/SDIO Host Controller Drivers" - --config MMC_BCM2835 -+config MMC_BCM2835_MMC - tristate "MMC support on BCM2835" - depends on MACH_BCM2708 || MACH_BCM2709 || ARCH_BCM2835 - help -@@ -16,7 +16,7 @@ config MMC_BCM2835 - - config MMC_BCM2835_DMA - bool "DMA support on BCM2835 Arasan controller" -- depends on MMC_BCM2835 -+ depends on MMC_BCM2835_MMC - help - Enable DMA support on the Arasan SDHCI controller in Broadcom 2708 - based chips. -diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile -index cd3a47d8965958ccf3ac3d186a05bbd437494154..9ba643d3b2e12960f5ce4b0eb5d75c1c360980ce 100644 ---- a/drivers/mmc/host/Makefile -+++ b/drivers/mmc/host/Makefile -@@ -18,7 +18,7 @@ obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o - obj-$(CONFIG_MMC_SDHCI_SIRF) += sdhci-sirf.o - obj-$(CONFIG_MMC_SDHCI_F_SDH30) += sdhci_f_sdh30.o - obj-$(CONFIG_MMC_SDHCI_SPEAR) += sdhci-spear.o --obj-$(CONFIG_MMC_BCM2835) += bcm2835-mmc.o -+obj-$(CONFIG_MMC_BCM2835_MMC) += bcm2835-mmc.o - obj-$(CONFIG_MMC_BCM2835_SDHOST) += bcm2835-sdhost.o - obj-$(CONFIG_MMC_WBSD) += wbsd.o - obj-$(CONFIG_MMC_AU1X) += au1xmmc.o - -From 9cd4ffbb09e60102daf319a8301806cc1025306f Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Tue, 16 May 2017 19:34:52 +0100 -Subject: [PATCH 122/199] config: Add CONFIG_I2C_ROBOTFUZZ_OSIF - ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index 93cdfa4ce3e7d3ff9f437a05a9ee6bcf4b895a20..4afeb9120a1d8411648c9ac685665aeb395af448 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -614,6 +614,7 @@ CONFIG_I2C_MUX_PCA954x=m - CONFIG_I2C_BCM2708=m - CONFIG_I2C_BCM2835=m - CONFIG_I2C_GPIO=m -+CONFIG_I2C_ROBOTFUZZ_OSIF=m - CONFIG_SPI=y - CONFIG_SPI_BCM2835=m - CONFIG_SPI_BCM2835AUX=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 29fd2abc2cbfcaed37cb630b5edffaa5b4994f6e..05d6d108cb2d013588ccc971c83dcd212308f230 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -610,6 +610,7 @@ CONFIG_I2C_MUX_PCA954x=m - CONFIG_I2C_BCM2708=m - CONFIG_I2C_BCM2835=m - CONFIG_I2C_GPIO=m -+CONFIG_I2C_ROBOTFUZZ_OSIF=m - CONFIG_SPI=y - CONFIG_SPI_BCM2835=m - CONFIG_SPI_BCM2835AUX=m - -From dfcd6c4844d7d84e31ff8fc483e986d4a67f9c11 Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Thu, 18 May 2017 11:40:43 +0100 -Subject: [PATCH 123/199] config: Add FB_TFT_ST7789V module - ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index 4afeb9120a1d8411648c9ac685665aeb395af448..cdf0206ea890c3843542f8f1db546e93e9a1f8ba 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -1138,6 +1138,7 @@ CONFIG_FB_TFT_SSD1306=m - CONFIG_FB_TFT_SSD1331=m - CONFIG_FB_TFT_SSD1351=m - CONFIG_FB_TFT_ST7735R=m -+CONFIG_FB_TFT_ST7789V=m - CONFIG_FB_TFT_TINYLCD=m - CONFIG_FB_TFT_TLS8204=m - CONFIG_FB_TFT_UC1701=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 05d6d108cb2d013588ccc971c83dcd212308f230..54175b3c558e89d56b7d65752bccc6bdaebcfd5a 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -1145,6 +1145,7 @@ CONFIG_FB_TFT_SSD1306=m - CONFIG_FB_TFT_SSD1331=m - CONFIG_FB_TFT_SSD1351=m - CONFIG_FB_TFT_ST7735R=m -+CONFIG_FB_TFT_ST7789V=m - CONFIG_FB_TFT_TINYLCD=m - CONFIG_FB_TFT_TLS8204=m - CONFIG_FB_TFT_UC1701=m - -From 0bae2d1c40795865ccb314128e49f85af7b52dcb Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Thu, 18 May 2017 15:36:46 +0100 -Subject: [PATCH 124/199] staging: bcm2835-audio: Fix memory corruption - -I'm all for fixing memory leaks, but freeing a block while it is still -being used is a recipe for hard-to-debug kernel exeptions. - -1) There is already a vchi method for freeing the instance, so use it. -2) Only call it on error, and then only before initted is false. - -Signed-off-by: Phil Elwell -Fixes: 0adbfd4694c2 ("staging: bcm2835-audio: fix memory leak in bcm2835_audio_open_connection()") ---- - drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c -index 5f3d8f2339e34834d11edfa8de1d5819e3e32b4f..89f96f3c02805f4114ec9b488e18d00e1f348239 100644 ---- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c -+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c -@@ -409,6 +409,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream - LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n", - __func__, ret); - -+ vchi_disconnect(vchi_instance); - ret = -EIO; - goto err_free_mem; - } -@@ -431,7 +432,6 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream - LOG_DBG(" success !\n"); - ret = 0; - err_free_mem: -- kfree(vchi_instance); - - return ret; - } - -From f200034fec4863c4af91348dd99ca0a26e328ecc Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Mon, 15 May 2017 16:40:05 +0100 -Subject: [PATCH 125/199] config: Add CONFIG_TOUCHSCREEN_GOODIX - ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 - - 2 files changed, 1 insertion(+), 1 deletion(-) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index cdf0206ea890c3843542f8f1db546e93e9a1f8ba..2624359759f0318290287c6201cf7e511367128d 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -566,6 +566,7 @@ CONFIG_INPUT_TOUCHSCREEN=y - CONFIG_TOUCHSCREEN_ADS7846=m - CONFIG_TOUCHSCREEN_EGALAX=m - CONFIG_TOUCHSCREEN_EDT_FT5X06=m -+CONFIG_TOUCHSCREEN_GOODIX=m - CONFIG_TOUCHSCREEN_RPI_FT5406=m - CONFIG_TOUCHSCREEN_USB_COMPOSITE=m - CONFIG_TOUCHSCREEN_STMPE=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 54175b3c558e89d56b7d65752bccc6bdaebcfd5a..1d2d27cb950b5e799370b7ca557f4bcb2508169b 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -560,7 +560,6 @@ CONFIG_JOYSTICK_RPISENSE=m - CONFIG_INPUT_TOUCHSCREEN=y - CONFIG_TOUCHSCREEN_ADS7846=m - CONFIG_TOUCHSCREEN_EGALAX=m --CONFIG_TOUCHSCREEN_EDT_FT5X06=m - CONFIG_TOUCHSCREEN_GOODIX=m - CONFIG_TOUCHSCREEN_RPI_FT5406=m - CONFIG_TOUCHSCREEN_USB_COMPOSITE=m - -From 4af04e40619bf2cbc3d51925d782e584c4b2cfd6 Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Tue, 16 May 2017 15:58:00 +0100 -Subject: [PATCH 126/199] config: Add CONFIG_TOUCHSCREEN_EDT_FT5X06 - ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index 2624359759f0318290287c6201cf7e511367128d..e1855e95ad612c5c615da8edd90b9b6cfd4e0807 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -567,6 +567,7 @@ CONFIG_TOUCHSCREEN_ADS7846=m - CONFIG_TOUCHSCREEN_EGALAX=m - CONFIG_TOUCHSCREEN_EDT_FT5X06=m - CONFIG_TOUCHSCREEN_GOODIX=m -+CONFIG_TOUCHSCREEN_EDT_FT5X06=m - CONFIG_TOUCHSCREEN_RPI_FT5406=m - CONFIG_TOUCHSCREEN_USB_COMPOSITE=m - CONFIG_TOUCHSCREEN_STMPE=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 1d2d27cb950b5e799370b7ca557f4bcb2508169b..de0b998202e23eec39fafce0e8cd346e68817f6c 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -561,6 +561,7 @@ CONFIG_INPUT_TOUCHSCREEN=y - CONFIG_TOUCHSCREEN_ADS7846=m - CONFIG_TOUCHSCREEN_EGALAX=m - CONFIG_TOUCHSCREEN_GOODIX=m -+CONFIG_TOUCHSCREEN_EDT_FT5X06=m - CONFIG_TOUCHSCREEN_RPI_FT5406=m - CONFIG_TOUCHSCREEN_USB_COMPOSITE=m - CONFIG_TOUCHSCREEN_STMPE=m - -From c3bb07909a287fb80ae3c0ed356c589b9fa5f4ed Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Mon, 22 May 2017 13:35:28 +0100 -Subject: [PATCH 127/199] config: Add CONFIG_IPV6_SIT_6RD - ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index e1855e95ad612c5c615da8edd90b9b6cfd4e0807..43928722d8f751b137d40ac22ae672bc6282c091 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -106,6 +106,7 @@ CONFIG_IPV6_ROUTER_PREF=y - CONFIG_INET6_AH=m - CONFIG_INET6_ESP=m - CONFIG_INET6_IPCOMP=m -+CONFIG_IPV6_SIT_6RD=y - CONFIG_IPV6_TUNNEL=m - CONFIG_IPV6_MULTIPLE_TABLES=y - CONFIG_IPV6_SUBTREES=y -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index de0b998202e23eec39fafce0e8cd346e68817f6c..c4d82bec0aefc191c6049500fbeda6ea0a47f590 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -101,6 +101,7 @@ CONFIG_IPV6_ROUTER_PREF=y - CONFIG_INET6_AH=m - CONFIG_INET6_ESP=m - CONFIG_INET6_IPCOMP=m -+CONFIG_IPV6_SIT_6RD=y - CONFIG_IPV6_TUNNEL=m - CONFIG_IPV6_MULTIPLE_TABLES=y - CONFIG_IPV6_SUBTREES=y - -From cf46fca414a06bf4afc633d2759295983f32b52b Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Mon, 22 May 2017 15:28:27 +0100 -Subject: [PATCH 128/199] config: Add CONFIG_IPV6_ROUTE_INFO - ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index 43928722d8f751b137d40ac22ae672bc6282c091..ba89462cf80f17e6275c1e7912d754d672d4c68d 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -103,6 +103,7 @@ CONFIG_TCP_CONG_ADVANCED=y - CONFIG_TCP_CONG_BBR=m - CONFIG_IPV6=m - CONFIG_IPV6_ROUTER_PREF=y -+CONFIG_IPV6_ROUTE_INFO=y - CONFIG_INET6_AH=m - CONFIG_INET6_ESP=m - CONFIG_INET6_IPCOMP=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index c4d82bec0aefc191c6049500fbeda6ea0a47f590..7d3522df2b28e53cb63a0813168918792b65becb 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -98,6 +98,7 @@ CONFIG_TCP_CONG_ADVANCED=y - CONFIG_TCP_CONG_BBR=m - CONFIG_IPV6=m - CONFIG_IPV6_ROUTER_PREF=y -+CONFIG_IPV6_ROUTE_INFO=y - CONFIG_INET6_AH=m - CONFIG_INET6_ESP=m - CONFIG_INET6_IPCOMP=m - -From e10daa78716bca9ad5158baed4fd4227d0a5d1ec Mon Sep 17 00:00:00 2001 -From: P33M -Date: Thu, 25 May 2017 16:04:53 +0100 -Subject: [PATCH 129/199] dwc_otg: make periodic scheduling behave properly for - FS buses - -If the root port is in full-speed mode, transfer times at 12mbit/s -would be calculated but matched against high-speed quotas. - -Reinitialise hcd->frame_usecs[i] on each port enable event so that -full-speed bandwidth can be tracked sensibly. - -Also, don't bother using the FIQ for transfers when in full-speed -mode - at the slower bus speed, interrupt frequency is reduced by -an order of magnitude. - -Related issue: https://github.com/raspberrypi/linux/issues/2020 ---- - drivers/usb/host/dwc_otg/dwc_otg_hcd.c | 15 ++++++++++----- - drivers/usb/host/dwc_otg/dwc_otg_hcd.h | 7 +++++-- - drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c | 4 ++++ - drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c | 19 ++++++++++++------- - 4 files changed, 31 insertions(+), 14 deletions(-) - -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -index a2dc6337836b2719f4c954edeeb2a71301931b04..38bf5fc792d32352f9e208e0e90f968599b9bc31 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -+++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -@@ -926,8 +926,6 @@ static void dwc_otg_hcd_free(dwc_otg_hcd_t * dwc_otg_hcd) - DWC_FREE(dwc_otg_hcd); - } - --int init_hcd_usecs(dwc_otg_hcd_t *_hcd); -- - int dwc_otg_hcd_init(dwc_otg_hcd_t * hcd, dwc_otg_core_if_t * core_if) - { - struct device *dev = dwc_otg_hcd_to_dev(hcd); -@@ -1429,6 +1427,7 @@ static void assign_and_init_hc(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh) - - /** - * fiq_fsm_transaction_suitable() - Test a QH for compatibility with the FIQ -+ * @hcd: Pointer to the dwc_otg_hcd struct - * @qh: pointer to the endpoint's queue head - * - * Transaction start/end control flow is grafted onto the existing dwc_otg -@@ -1438,8 +1437,14 @@ static void assign_and_init_hc(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh) - * Returns: 0 for unsuitable, 1 implies the FIQ can be enabled for this transaction. - */ - --int fiq_fsm_transaction_suitable(dwc_otg_qh_t *qh) -+int fiq_fsm_transaction_suitable(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) - { -+ /* There is little benefit in using the FIQ to perform transfers if -+ * the root port is not in high-speed mode. -+ */ -+ if (hcd->flags.b.port_speed != DWC_HPRT0_PRTSPD_HIGH_SPEED) -+ return 0; -+ - if (qh->do_split) { - switch (qh->ep_type) { - case UE_CONTROL: -@@ -2218,7 +2223,7 @@ static void process_periodic_channels(dwc_otg_hcd_t * hcd) - continue; - } - -- if (fiq_fsm_enable && fiq_fsm_transaction_suitable(qh)) { -+ if (fiq_fsm_enable && fiq_fsm_transaction_suitable(hcd, qh)) { - if (qh->do_split) - fiq_fsm_queue_split_transaction(hcd, qh); - else -@@ -2355,7 +2360,7 @@ static void process_non_periodic_channels(dwc_otg_hcd_t * hcd) - qh = DWC_LIST_ENTRY(hcd->non_periodic_qh_ptr, dwc_otg_qh_t, - qh_list_entry); - -- if(fiq_fsm_enable && fiq_fsm_transaction_suitable(qh)) { -+ if(fiq_fsm_enable && fiq_fsm_transaction_suitable(hcd, qh)) { - fiq_fsm_queue_split_transaction(hcd, qh); - } else { - status = queue_transaction(hcd, qh->channel, -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.h b/drivers/usb/host/dwc_otg/dwc_otg_hcd.h -index 7f7e9eaffd6a3c3d898855562fbec11289f77f53..5ed8dccf03959a610849aa6c8946ca745dbae207 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_hcd.h -+++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.h -@@ -410,7 +410,8 @@ struct dwc_otg_hcd { - unsigned port_suspend_change:1; - unsigned port_over_current_change:1; - unsigned port_l1_change:1; -- unsigned reserved:26; -+ unsigned port_speed:2; -+ unsigned reserved:24; - } b; - } flags; - -@@ -629,7 +630,7 @@ int dwc_otg_hcd_allocate_port(dwc_otg_hcd_t * hcd, dwc_otg_qh_t *qh); - void dwc_otg_hcd_release_port(dwc_otg_hcd_t * dwc_otg_hcd, dwc_otg_qh_t *qh); - - extern int fiq_fsm_queue_transaction(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh); --extern int fiq_fsm_transaction_suitable(dwc_otg_qh_t *qh); -+extern int fiq_fsm_transaction_suitable(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh); - extern void dwc_otg_cleanup_fiq_channel(dwc_otg_hcd_t *hcd, uint32_t num); - - /** @} */ -@@ -823,6 +824,8 @@ static inline uint16_t dwc_micro_frame_num(uint16_t frame) - return frame & 0x7; - } - -+extern void init_hcd_usecs(dwc_otg_hcd_t *_hcd); -+ - void dwc_otg_hcd_save_data_toggle(dwc_hc_t * hc, - dwc_otg_hc_regs_t * hc_regs, - dwc_otg_qtd_t * qtd); -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c -index a4355afc77b68718fdaba6c5d4be257dadc75036..c8f52709a7d24974c0a38dcf1708f91073e96b0e 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c -+++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c -@@ -515,6 +515,10 @@ int32_t dwc_otg_hcd_handle_port_intr(dwc_otg_hcd_t * dwc_otg_hcd) - dwc_otg_host_if_t *host_if = - dwc_otg_hcd->core_if->host_if; - -+ dwc_otg_hcd->flags.b.port_speed = hprt0.b.prtspd; -+ if (microframe_schedule) -+ init_hcd_usecs(dwc_otg_hcd); -+ - /* Every time when port enables calculate - * HFIR.FrInterval - */ -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c -index 85a6d431ca54b47dc10573aa72d1ad69d06f2e36..4b1dd9de99e9e08b2e006fb5f8a7ef92f20c2553 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c -+++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c -@@ -408,13 +408,17 @@ const unsigned short max_uframe_usecs[]={ 100, 100, 100, 100, 100, 100, 30, 0 }; - /* - * called from dwc_otg_hcd.c:dwc_otg_hcd_init - */ --int init_hcd_usecs(dwc_otg_hcd_t *_hcd) -+void init_hcd_usecs(dwc_otg_hcd_t *_hcd) - { - int i; -- for (i=0; i<8; i++) { -- _hcd->frame_usecs[i] = max_uframe_usecs[i]; -+ if (_hcd->flags.b.port_speed == DWC_HPRT0_PRTSPD_FULL_SPEED) { -+ _hcd->frame_usecs[0] = 900; -+ for (i = 1; i < 8; i++) -+ _hcd->frame_usecs[i] = 0; -+ } else { -+ for (i = 0; i < 8; i++) -+ _hcd->frame_usecs[i] = max_uframe_usecs[i]; - } -- return 0; - } - - static int find_single_uframe(dwc_otg_hcd_t * _hcd, dwc_otg_qh_t * _qh) -@@ -541,8 +545,9 @@ static int find_uframe(dwc_otg_hcd_t * _hcd, dwc_otg_qh_t * _qh) - int ret; - ret = -1; - -- if (_qh->speed == USB_SPEED_HIGH) { -- /* if this is a hs transaction we need a full frame */ -+ if (_qh->speed == USB_SPEED_HIGH || -+ _hcd->flags.b.port_speed == DWC_HPRT0_PRTSPD_FULL_SPEED) { -+ /* if this is a hs transaction we need a full frame - or account for FS usecs */ - ret = find_single_uframe(_hcd, _qh); - } else { - /* if this is a fs transaction we may need a sequence of frames */ -@@ -627,7 +632,7 @@ static int schedule_periodic(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh) - if (status) { - DWC_INFO("%s: Insufficient periodic bandwidth for " - "periodic transfer.\n", __func__); -- return status; -+ return -DWC_E_NO_SPACE; - } - status = check_max_xfer_size(hcd, qh); - if (status) { - -From bb023a9ad949c9cd663edfe38722b29ba44ffb57 Mon Sep 17 00:00:00 2001 -From: P33M -Date: Fri, 26 May 2017 12:50:31 +0100 -Subject: [PATCH 130/199] dwc_otg: fiq_fsm: Make isochronous compatibility - checks work properly - -Get rid of the spammy printk and local pointer mangling. -Also, there is a nominal benefit for using fiq_fsm for isochronous -transfers in FS mode (~1.1k IRQs per second vs 2.1k IRQs per second) -so remove the root port speed check. ---- - drivers/usb/host/dwc_otg/dwc_otg_hcd.c | 24 ++++++------------------ - 1 file changed, 6 insertions(+), 18 deletions(-) - -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -index 38bf5fc792d32352f9e208e0e90f968599b9bc31..71834cf365e67d7ad995bba7869216c4091c3a74 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -+++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -@@ -1439,12 +1439,6 @@ static void assign_and_init_hc(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh) - - int fiq_fsm_transaction_suitable(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) - { -- /* There is little benefit in using the FIQ to perform transfers if -- * the root port is not in high-speed mode. -- */ -- if (hcd->flags.b.port_speed != DWC_HPRT0_PRTSPD_HIGH_SPEED) -- return 0; -- - if (qh->do_split) { - switch (qh->ep_type) { - case UE_CONTROL: -@@ -1462,28 +1456,22 @@ int fiq_fsm_transaction_suitable(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) - } - } else if (qh->ep_type == UE_ISOCHRONOUS) { - if (fiq_fsm_mask & (1 << 2)) { -- /* HS ISOCH support. We test for compatibility: -+ /* ISOCH support. We test for compatibility: - * - DWORD aligned buffers - * - Must be at least 2 transfers (otherwise pointless to use the FIQ) - * If yes, then the fsm enqueue function will handle the state machine setup. - */ - dwc_otg_qtd_t *qtd = DWC_CIRCLEQ_FIRST(&qh->qtd_list); - dwc_otg_hcd_urb_t *urb = qtd->urb; -- struct dwc_otg_hcd_iso_packet_desc (*iso_descs)[0] = &urb->iso_descs; -- int nr_iso_frames = urb->packet_count; -+ dwc_dma_t ptr; - int i; -- uint32_t ptr; - -- if (nr_iso_frames < 2) -+ if (urb->packet_count < 2) - return 0; -- for (i = 0; i < nr_iso_frames; i++) { -- ptr = urb->dma + iso_descs[i]->offset; -- if (ptr & 0x3) { -- printk_ratelimited("%s: Non-Dword aligned isochronous frame offset." -- " Cannot queue FIQ-accelerated transfer to device %d endpoint %d\n", -- __FUNCTION__, qh->channel->dev_addr, qh->channel->ep_num); -+ for (i = 0; i < urb->packet_count; i++) { -+ ptr = urb->dma + urb->iso_descs[i].offset; -+ if (ptr & 0x3) - return 0; -- } - } - return 1; - } - -From 4cfbb24e2238bb51f10fa60bc822f6bbf1925cab Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Mon, 12 Jun 2017 13:05:43 +0100 -Subject: [PATCH 131/199] config: Add CONFIG_CAN_GS_USB - ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index ba89462cf80f17e6275c1e7912d754d672d4c68d..fd6d3980bc003801a6868e6098f3868a2544573f 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -362,6 +362,7 @@ CONFIG_CAN=m - CONFIG_CAN_VCAN=m - CONFIG_CAN_SLCAN=m - CONFIG_CAN_MCP251X=m -+CONFIG_CAN_GS_USB=m - CONFIG_IRDA=m - CONFIG_IRLAN=m - CONFIG_IRNET=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 7d3522df2b28e53cb63a0813168918792b65becb..bf0d3fd830a0a0cc9443ef52e7f167eb704ed152 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -357,6 +357,7 @@ CONFIG_CAN=m - CONFIG_CAN_VCAN=m - CONFIG_CAN_SLCAN=m - CONFIG_CAN_MCP251X=m -+CONFIG_CAN_GS_USB=m - CONFIG_IRDA=m - CONFIG_IRLAN=m - CONFIG_IRNET=m - -From 3c9883d6f804e2587367849e3933d61a5602b0a6 Mon Sep 17 00:00:00 2001 -From: P33M -Date: Mon, 12 Jun 2017 16:10:03 +0100 -Subject: [PATCH 132/199] dwc_otg: add module parameter int_ep_interval_min - -Add a module parameter (defaulting to ignored) that clamps the polling rate -of high-speed Interrupt endpoints to a minimum microframe interval. - -The parameter is modifiable at runtime as it is used when activating new -endpoints (such as on device connect). ---- - drivers/usb/host/dwc_otg/dwc_otg_driver.c | 6 +++++- - drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c | 25 ++++++++++++------------- - 2 files changed, 17 insertions(+), 14 deletions(-) - -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_driver.c b/drivers/usb/host/dwc_otg/dwc_otg_driver.c -index cb060a7179a3eec791506ed2779b553cad9841b0..95943e07528276b26b51ea2d57a1f433f280aaef 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_driver.c -+++ b/drivers/usb/host/dwc_otg/dwc_otg_driver.c -@@ -249,6 +249,7 @@ uint16_t nak_holdoff = 8; - - unsigned short fiq_fsm_mask = 0x0F; - -+unsigned short int_ep_interval_min = 0; - /** - * This function shows the Driver Version. - */ -@@ -1398,7 +1399,10 @@ MODULE_PARM_DESC(fiq_fsm_mask, "Bitmask of transactions to perform in the FIQ.\n - "Bit 1 : Periodic split transactions\n" - "Bit 2 : High-speed multi-transfer isochronous\n" - "All other bits should be set 0."); -- -+module_param(int_ep_interval_min, ushort, 0644); -+MODULE_PARM_DESC(int_ep_interval_min, "Clamp high-speed Interrupt endpoints to a minimum polling interval.\n" -+ "0..1 = Use endpoint default\n" -+ "2..n = Minimum interval n microframes. Use powers of 2.\n"); - - /** @page "Module Parameters" - * -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c -index 4b1dd9de99e9e08b2e006fb5f8a7ef92f20c2553..fe8e8f841f03660c2ad49ab8e66193bec62558d3 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c -+++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c -@@ -43,6 +43,7 @@ - #include "dwc_otg_regs.h" - - extern bool microframe_schedule; -+extern unsigned short int_ep_interval_min; - - /** - * Free each QTD in the QH's QTD-list then free the QH. QH should already be -@@ -218,21 +219,19 @@ void qh_init(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh, dwc_otg_hcd_urb_t * urb) - SCHEDULE_SLOP); - qh->interval = urb->interval; - --#if 0 -- /* Increase interrupt polling rate for debugging. */ -- if (qh->ep_type == UE_INTERRUPT) { -- qh->interval = 8; -- } --#endif - hprt.d32 = DWC_READ_REG32(hcd->core_if->host_if->hprt0); -- if ((hprt.b.prtspd == DWC_HPRT0_PRTSPD_HIGH_SPEED) && -- ((dev_speed == USB_SPEED_LOW) || -- (dev_speed == USB_SPEED_FULL))) { -- qh->interval *= 8; -- qh->sched_frame |= 0x7; -- qh->start_split_frame = qh->sched_frame; -+ if (hprt.b.prtspd == DWC_HPRT0_PRTSPD_HIGH_SPEED) { -+ if (dev_speed == USB_SPEED_LOW || -+ dev_speed == USB_SPEED_FULL) { -+ qh->interval *= 8; -+ qh->sched_frame |= 0x7; -+ qh->start_split_frame = qh->sched_frame; -+ } else if (int_ep_interval_min >= 2 && -+ qh->interval < int_ep_interval_min && -+ qh->ep_type == UE_INTERRUPT) { -+ qh->interval = int_ep_interval_min; -+ } - } -- - } - - DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD QH Initialized\n"); - -From 1d6e58ced8a05ed7164cb9716c51ba016fb16191 Mon Sep 17 00:00:00 2001 -From: P33M -Date: Tue, 20 Jun 2017 13:44:01 +0100 -Subject: [PATCH 133/199] dwc_otg: fiq_fsm: Add non-periodic TT exclusivity - constraints - -Certain hub types do not discriminate between pipe direction (IN or OUT) -when considering non-periodic transfers. Therefore these hubs get confused -if multiple transfers are issued in different directions with the same -device address and endpoint number. - -Constrain queuing non-periodic split transactions so they are performed -serially in such cases. - -Related: https://github.com/raspberrypi/linux/issues/2024 ---- - drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c | 32 ++++++++++++++++++ - drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h | 2 ++ - drivers/usb/host/dwc_otg/dwc_otg_hcd.c | 53 ++++++++++++++++++++++++++++-- - 3 files changed, 85 insertions(+), 2 deletions(-) - -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c -index 208252645c09d1d17bf07673989f91b7f4b3ef7a..0163e9cf620ba58df36a872b82cea92734baada6 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c -+++ b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c -@@ -191,6 +191,32 @@ static void notrace fiq_fsm_setup_csplit(struct fiq_state *st, int n) - mb(); - } - -+/** -+ * fiq_fsm_restart_np_pending() - Restart a single non-periodic contended transfer -+ * @st: Pointer to the channel's state -+ * @num_channels: Total number of host channels -+ * @orig_channel: Channel index of completed transfer -+ * -+ * In the case where an IN and OUT transfer are simultaneously scheduled to the -+ * same device/EP, inadequate hub implementations will misbehave. Once the first -+ * transfer is complete, a pending non-periodic split can then be issued. -+ */ -+static void notrace fiq_fsm_restart_np_pending(struct fiq_state *st, int num_channels, int orig_channel) -+{ -+ int i; -+ int dev_addr = st->channel[orig_channel].hcchar_copy.b.devaddr; -+ int ep_num = st->channel[orig_channel].hcchar_copy.b.epnum; -+ for (i = 0; i < num_channels; i++) { -+ if (st->channel[i].fsm == FIQ_NP_SSPLIT_PENDING && -+ st->channel[i].hcchar_copy.b.devaddr == dev_addr && -+ st->channel[i].hcchar_copy.b.epnum == ep_num) { -+ st->channel[i].fsm = FIQ_NP_SSPLIT_STARTED; -+ fiq_fsm_restart_channel(st, i, 0); -+ break; -+ } -+ } -+} -+ - static inline int notrace fiq_get_xfer_len(struct fiq_state *st, int n) - { - /* The xfersize register is a bit wonky. For IN transfers, it decrements by the packet size. */ -@@ -870,6 +896,9 @@ static int notrace noinline fiq_fsm_do_hcintr(struct fiq_state *state, int num_c - st->fsm = FIQ_NP_SPLIT_HS_ABORTED; - } - } -+ if (st->fsm != FIQ_NP_IN_CSPLIT_RETRY) { -+ fiq_fsm_restart_np_pending(state, num_channels, n); -+ } - break; - - case FIQ_NP_OUT_CSPLIT_RETRY: -@@ -919,6 +948,9 @@ static int notrace noinline fiq_fsm_do_hcintr(struct fiq_state *state, int num_c - st->fsm = FIQ_NP_SPLIT_HS_ABORTED; - } - } -+ if (st->fsm != FIQ_NP_OUT_CSPLIT_RETRY) { -+ fiq_fsm_restart_np_pending(state, num_channels, n); -+ } - break; - - /* Periodic split states (except isoc out) */ -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h -index 0a1ddf3f89f45ca75b8880722fbc22cbdc9f4a2f..ed088f34f210e9a337ab9b80fff0cf9e9b0241ea 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h -+++ b/drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h -@@ -178,6 +178,8 @@ enum fiq_fsm_state { - /* Nonperiodic state groups */ - FIQ_NP_SSPLIT_STARTED = 1, - FIQ_NP_SSPLIT_RETRY = 2, -+ /* TT contention - working around hub bugs */ -+ FIQ_NP_SSPLIT_PENDING = 33, - FIQ_NP_OUT_CSPLIT_RETRY = 3, - FIQ_NP_IN_CSPLIT_RETRY = 4, - FIQ_NP_SPLIT_DONE = 5, -diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -index 71834cf365e67d7ad995bba7869216c4091c3a74..7710370b30363e3170bf9bf522597c5f41dfb908 100644 ---- a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -+++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c -@@ -1572,6 +1572,45 @@ int fiq_fsm_setup_periodic_dma(dwc_otg_hcd_t *hcd, struct fiq_channel_state *st, - } - } - -+/** -+ * fiq_fsm_np_tt_contended() - Avoid performing contended non-periodic transfers -+ * @hcd: Pointer to the dwc_otg_hcd struct -+ * @qh: Pointer to the endpoint's queue head -+ * -+ * Certain hub chips don't differentiate between IN and OUT non-periodic pipes -+ * with the same endpoint number. If transfers get completed out of order -+ * (disregarding the direction token) then the hub can lock up -+ * or return erroneous responses. -+ * -+ * Returns 1 if initiating the transfer would cause contention, 0 otherwise. -+ */ -+int fiq_fsm_np_tt_contended(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) -+{ -+ int i; -+ struct fiq_channel_state *st; -+ int dev_addr = qh->channel->dev_addr; -+ int ep_num = qh->channel->ep_num; -+ for (i = 0; i < hcd->core_if->core_params->host_channels; i++) { -+ if (i == qh->channel->hc_num) -+ continue; -+ st = &hcd->fiq_state->channel[i]; -+ switch (st->fsm) { -+ case FIQ_NP_SSPLIT_STARTED: -+ case FIQ_NP_SSPLIT_RETRY: -+ case FIQ_NP_SSPLIT_PENDING: -+ case FIQ_NP_OUT_CSPLIT_RETRY: -+ case FIQ_NP_IN_CSPLIT_RETRY: -+ if (st->hcchar_copy.b.devaddr == dev_addr && -+ st->hcchar_copy.b.epnum == ep_num) -+ return 1; -+ break; -+ default: -+ break; -+ } -+ } -+ return 0; -+} -+ - /* - * Pushing a periodic request into the queue near the EOF1 point - * in a microframe causes erroneous behaviour (frmovrun) interrupt. -@@ -1894,7 +1933,12 @@ int fiq_fsm_queue_split_transaction(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) - switch (hc->ep_type) { - case UE_CONTROL: - case UE_BULK: -- st->fsm = FIQ_NP_SSPLIT_STARTED; -+ if (fiq_fsm_np_tt_contended(hcd, qh)) { -+ st->fsm = FIQ_NP_SSPLIT_PENDING; -+ start_immediate = 0; -+ } else { -+ st->fsm = FIQ_NP_SSPLIT_STARTED; -+ } - break; - case UE_ISOCHRONOUS: - if (hc->ep_is_in) { -@@ -1918,7 +1962,12 @@ int fiq_fsm_queue_split_transaction(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) - break; - case UE_INTERRUPT: - if (fiq_fsm_mask & 0x8) { -- st->fsm = FIQ_NP_SSPLIT_STARTED; -+ if (fiq_fsm_np_tt_contended(hcd, qh)) { -+ st->fsm = FIQ_NP_SSPLIT_PENDING; -+ start_immediate = 0; -+ } else { -+ st->fsm = FIQ_NP_SSPLIT_STARTED; -+ } - } else if (start_immediate) { - st->fsm = FIQ_PER_SSPLIT_STARTED; - } else { - -From a345856a599d7b5cdb9269843d39a54628948590 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Fri, 26 May 2017 13:03:41 +0100 -Subject: [PATCH 134/199] BCM270X_DT: Add midi-uart1 overlay - -Add a scaler to the ttyS0 clock so that requesting 38400 baud results -in an approximately 31250 baud signal. This is analagous to -midi-uart0, except for ttyS0, which may be useful on Pi3 and also -may avoid an issue with ttyAMA0 failing to synchronise to an active -data stream. - -See: https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=183860 - -Signed-off-by: Phil Elwell ---- - arch/arm/boot/dts/overlays/Makefile | 1 + - arch/arm/boot/dts/overlays/README | 7 ++++ - arch/arm/boot/dts/overlays/midi-uart1-overlay.dts | 43 +++++++++++++++++++++++ - 3 files changed, 51 insertions(+) - create mode 100644 arch/arm/boot/dts/overlays/midi-uart1-overlay.dts - -diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile -index e2f66a55dc5afe13d690c2c17827054ac94b7168..e0ff5793f124fce73732e175bfca424f0a97b632 100644 ---- a/arch/arm/boot/dts/overlays/Makefile -+++ b/arch/arm/boot/dts/overlays/Makefile -@@ -56,6 +56,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ - mcp2515-can1.dtbo \ - mcp3008.dtbo \ - midi-uart0.dtbo \ -+ midi-uart1.dtbo \ - mmc.dtbo \ - mz61581.dtbo \ - pi3-act-led.dtbo \ -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index e2a803e5180cf78d67b6723cfd2f6d3b2b54e53b..ec9e7b1941678796facf625b3770c20ed0b15b25 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -864,6 +864,13 @@ Load: dtoverlay=midi-uart0 - Params: - - -+Name: midi-uart1 -+Info: Configures UART1 (ttyS0) so that a requested 38.4kbaud actually gets -+ 31.25kbaud, the frequency required for MIDI -+Load: dtoverlay=midi-uart1 -+Params: -+ -+ - Name: mmc - Info: Selects the bcm2835-mmc SD/MMC driver, optionally with overclock - Load: dtoverlay=mmc,= -diff --git a/arch/arm/boot/dts/overlays/midi-uart1-overlay.dts b/arch/arm/boot/dts/overlays/midi-uart1-overlay.dts -new file mode 100644 -index 0000000000000000000000000000000000000000..e0bc410acbff3a7a175dd5d53b3ab0d0802e8239 ---- /dev/null -+++ b/arch/arm/boot/dts/overlays/midi-uart1-overlay.dts -@@ -0,0 +1,43 @@ -+/dts-v1/; -+/plugin/; -+ -+#include -+ -+/* -+ * Fake a higher clock rate to get a larger divisor, and thereby a lower -+ * baudrate. The real clock is 48MHz, which we scale so that requesting -+ * 38.4kHz results in an actual 31.25kHz. -+ * -+ * 48000000*38400/31250 = 58982400 -+ */ -+ -+/{ -+ compatible = "brcm,bcm2835"; -+ -+ fragment@0 { -+ target-path = "/clocks"; -+ __overlay__ { -+ midi_clk: clock@5 { -+ compatible = "fixed-factor-clock"; -+ #clock-cells = <0>; -+ clocks = <&aux BCM2835_AUX_CLOCK_UART>; -+ clock-mult = <38400>; -+ clock-div = <31250>; -+ }; -+ }; -+ }; -+ -+ fragment@1 { -+ target = <&uart1>; -+ __overlay__ { -+ clocks = <&midi_clk>; -+ }; -+ }; -+ -+ fragment@2 { -+ target = <&aux>; -+ __overlay__ { -+ clock-output-names = "aux_uart", "aux_spi1", "aux_spi2"; -+ }; -+ }; -+}; - -From d33071b43b6688a09e4c62697ed1c345ca6e3f13 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Sat, 20 May 2017 22:10:14 +0100 -Subject: [PATCH 135/199] overlays: README: remove vestigial SDIO parameters - -Signed-off-by: Phil Elwell ---- - arch/arm/boot/dts/overlays/README | 24 ++---------------------- - 1 file changed, 2 insertions(+), 22 deletions(-) - -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index ec9e7b1941678796facf625b3770c20ed0b15b25..499cd1920fd373702cfbc9f6e0fcaebca8a47cfc 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -1203,19 +1203,9 @@ Name: sdio - Info: Selects the bcm2835-sdhost SD/MMC driver, optionally with overclock, - and enables SDIO via GPIOs 22-27. - Load: dtoverlay=sdio,= --Params: overclock_50 SD Clock (in MHz) to use when the MMC framework -- requests 50MHz -- -- sdio_overclock SDIO Clock (in MHz) to use when the MMC -+Params: sdio_overclock SDIO Clock (in MHz) to use when the MMC - framework requests 50MHz - -- force_pio Disable DMA support (default off) -- -- pio_limit Number of blocks above which to use DMA -- (default 1) -- -- debug Enable debug output (default off) -- - poll_once Disable SDIO-device polling every second - (default on: polling once at boot-time) - -@@ -1226,19 +1216,9 @@ Name: sdio-1bit - Info: Selects the bcm2835-sdhost SD/MMC driver, optionally with overclock, - and enables 1-bit SDIO via GPIOs 22-25. - Load: dtoverlay=sdio-1bit,= --Params: overclock_50 SD Clock (in MHz) to use when the MMC framework -- requests 50MHz -- -- sdio_overclock SDIO Clock (in MHz) to use when the MMC -+Params: sdio_overclock SDIO Clock (in MHz) to use when the MMC - framework requests 50MHz - -- force_pio Disable DMA support (default off) -- -- pio_limit Number of blocks above which to use DMA -- (default 1) -- -- debug Enable debug output (default off) -- - poll_once Disable SDIO-device polling every second - (default on: polling once at boot-time) - - -From c405f6be721dfb65855b0d4ab53404e06bd55342 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Tue, 27 Jun 2017 15:07:14 +0100 -Subject: [PATCH 136/199] SQUASH: mmc: Apply ERASE_BROKEN quirks correctly - -Squash with: mmc: Add MMC_QUIRK_ERASE_BROKEN for some cards - -Signed-off-by: Phil Elwell ---- - drivers/mmc/core/quirks.h | 9 +++------ - 1 file changed, 3 insertions(+), 6 deletions(-) - -diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h -index 05c8d7381fff5ae88531129d9a5ddd554bddb43e..c9d5d644688c1509d7febcff0322fbaba0a842d6 100644 ---- a/drivers/mmc/core/quirks.h -+++ b/drivers/mmc/core/quirks.h -@@ -94,12 +94,9 @@ static const struct mmc_fixup mmc_blk_fixups[] = { - * On some Kingston SD cards, multiple erases of less than 64 - * sectors can cause corruption. - */ -- MMC_FIXUP("SD16G", 0x41, 0x3432, add_quirk_mmc, -- MMC_QUIRK_ERASE_BROKEN), -- MMC_FIXUP("SD32G", 0x41, 0x3432, add_quirk_mmc, -- MMC_QUIRK_ERASE_BROKEN), -- MMC_FIXUP("SD64G", 0x41, 0x3432, add_quirk_mmc, -- MMC_QUIRK_ERASE_BROKEN), -+ MMC_FIXUP("SD16G", 0x41, 0x3432, add_quirk, MMC_QUIRK_ERASE_BROKEN), -+ MMC_FIXUP("SD32G", 0x41, 0x3432, add_quirk, MMC_QUIRK_ERASE_BROKEN), -+ MMC_FIXUP("SD64G", 0x41, 0x3432, add_quirk, MMC_QUIRK_ERASE_BROKEN), - - END_FIXUP - }; - -From bb939d3addc2a8f7b00594d505d5bcd55d937efc Mon Sep 17 00:00:00 2001 +From 703fb6dc2bdb896d92907e25bddbb47c02a95a3f Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Sun, 7 May 2017 11:34:26 +0200 -Subject: [PATCH 137/199] ASoC: bcm2835: Add support for TDM modes +Subject: [PATCH 124/129] ASoC: bcm2835: Add support for TDM modes bcm2835 supports arbitrary positioning of channel data within a frame and thus is capable of supporting TDM modes. Since @@ -133425,10 +134321,10 @@ index 56df7d8a43d0aac055a91b0d24aca8e1b4e308e4..dcacf7f83c9371df539a788ea33fedcf dev->dev = &pdev->dev; dev_set_drvdata(&pdev->dev, dev); -From 434bd197a2ff514fec1b6b586a917c6e456ac677 Mon Sep 17 00:00:00 2001 +From dd338425587a3c4d54f218f6b4d8353e1b8e166b Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Sun, 7 May 2017 15:30:50 +0200 -Subject: [PATCH 138/199] ASoC: bcm2835: Support left/right justified and DSP +Subject: [PATCH 125/129] ASoC: bcm2835: Support left/right justified and DSP modes DSP modes and left/right justified modes can be supported @@ -133674,10 +134570,10 @@ index dcacf7f83c9371df539a788ea33fedcf97d64690..3a706fda4f39e42efbe12f19d87af9b1 } -From e8496ced09fb935883a10511297df0824c119a56 Mon Sep 17 00:00:00 2001 +From 129ca2a27effd87c3d6aae09e357cc4f5deb636c Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Sun, 7 May 2017 16:19:54 +0200 -Subject: [PATCH 139/199] ASoC: bcm2835: Support additional samplerates up to +Subject: [PATCH 126/129] ASoC: bcm2835: Support additional samplerates up to 384kHz Sample rates are only restricted by the capabilities of the @@ -133720,10 +134616,10 @@ index 3a706fda4f39e42efbe12f19d87af9b100a348a5..43f5715a0d5dda851731ecf7ff27e76c | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE -From 80825cda0b5cddc0748e4905215516d2e8f107e3 Mon Sep 17 00:00:00 2001 +From 21821e1d5caa6534029429200d5488d989f5cb16 Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Sun, 7 May 2017 16:24:57 +0200 -Subject: [PATCH 140/199] ASoC: bcm2835: Enforce full symmetry +Subject: [PATCH 127/129] ASoC: bcm2835: Enforce full symmetry bcm2835's configuration registers can't be changed when a stream is running, which means asymmetric configurations aren't supported. @@ -133759,1643 +134655,10 @@ index 43f5715a0d5dda851731ecf7ff27e76c48fb6e57..2e449d7173fcecbcd647f90a26bd58b6 static bool bcm2835_i2s_volatile_reg(struct device *dev, unsigned int reg) -From 998ecd6e3522528d2f1bcae09e3d999ee7b9dc3c Mon Sep 17 00:00:00 2001 -From: Matthias Reichl -Date: Thu, 6 Jul 2017 18:52:16 +0200 -Subject: [PATCH 141/199] config: add missing arizona regulator modules - -In kernel 4.12 CONFIG_REGULATOR_ARIZONA was replaced by 2 separate -options for LDO1 and MICSUPP regulators. Enable these, they are -needed by the Cirrus Logic Audio Card. - -Also regenerate configs with make savedefconfig to get rid of -the duplicated CONFIG_TOUCHSCREEN_EDT_FT5X06 entry. - -Signed-off-by: Matthias Reichl ---- - arch/arm/configs/bcm2709_defconfig | 3 ++- - arch/arm/configs/bcmrpi_defconfig | 2 ++ - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index fd6d3980bc003801a6868e6098f3868a2544573f..95da3daaf33c7cfab76f6af397e058e9ed8d998f 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -568,7 +568,6 @@ CONFIG_JOYSTICK_RPISENSE=m - CONFIG_INPUT_TOUCHSCREEN=y - CONFIG_TOUCHSCREEN_ADS7846=m - CONFIG_TOUCHSCREEN_EGALAX=m --CONFIG_TOUCHSCREEN_EDT_FT5X06=m - CONFIG_TOUCHSCREEN_GOODIX=m - CONFIG_TOUCHSCREEN_EDT_FT5X06=m - CONFIG_TOUCHSCREEN_RPI_FT5406=m -@@ -671,6 +670,8 @@ CONFIG_MFD_ARIZONA_SPI=m - CONFIG_MFD_WM5102=y - CONFIG_REGULATOR=y - CONFIG_REGULATOR_FIXED_VOLTAGE=m -+CONFIG_REGULATOR_ARIZONA_LDO1=m -+CONFIG_REGULATOR_ARIZONA_MICSUPP=m - CONFIG_MEDIA_SUPPORT=m - CONFIG_MEDIA_CAMERA_SUPPORT=y - CONFIG_MEDIA_ANALOG_TV_SUPPORT=y -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index bf0d3fd830a0a0cc9443ef52e7f167eb704ed152..06d0520e332f21afaa27ac112c0eee6c36a9a9df 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -663,6 +663,8 @@ CONFIG_MFD_ARIZONA_SPI=m - CONFIG_MFD_WM5102=y - CONFIG_REGULATOR=y - CONFIG_REGULATOR_FIXED_VOLTAGE=m -+CONFIG_REGULATOR_ARIZONA_LDO1=m -+CONFIG_REGULATOR_ARIZONA_MICSUPP=m - CONFIG_MEDIA_SUPPORT=m - CONFIG_MEDIA_CAMERA_SUPPORT=y - CONFIG_MEDIA_ANALOG_TV_SUPPORT=y - -From 43ecf468282a9d298028b5a46012e7d4e08fc74d Mon Sep 17 00:00:00 2001 -From: Matt Flax -Date: Tue, 4 Apr 2017 19:20:59 +1000 -Subject: [PATCH 142/199] Audioinjector : make the octo and pi sound cards have - different driver names - -This patch gives the audioinjector octo and pi soundcards different driver -names. This allows both the be loaded without clashing. ---- - sound/soc/bcm/audioinjector-octo-soundcard.c | 2 +- - sound/soc/bcm/audioinjector-pi-soundcard.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/sound/soc/bcm/audioinjector-octo-soundcard.c b/sound/soc/bcm/audioinjector-octo-soundcard.c -index dcf403ab37639ba79e38278d7e4b1ade452c292a..49115c8e20ce1a2ba5a99feb8983a1cafb052ca2 100644 ---- a/sound/soc/bcm/audioinjector-octo-soundcard.c -+++ b/sound/soc/bcm/audioinjector-octo-soundcard.c -@@ -324,7 +324,7 @@ MODULE_DEVICE_TABLE(of, audioinjector_octo_of_match); - - static struct platform_driver audioinjector_octo_driver = { - .driver = { -- .name = "audioinjector-audio", -+ .name = "audioinjector-octo", - .owner = THIS_MODULE, - .of_match_table = audioinjector_octo_of_match, - }, -diff --git a/sound/soc/bcm/audioinjector-pi-soundcard.c b/sound/soc/bcm/audioinjector-pi-soundcard.c -index ef54e0f07ea03f59e9957b5d98f3e7fdc998e469..491906bbf446826e55dd843f28e4860f48e908b8 100644 ---- a/sound/soc/bcm/audioinjector-pi-soundcard.c -+++ b/sound/soc/bcm/audioinjector-pi-soundcard.c -@@ -177,7 +177,7 @@ MODULE_DEVICE_TABLE(of, audioinjector_pi_soundcard_of_match); - - static struct platform_driver audioinjector_pi_soundcard_driver = { - .driver = { -- .name = "audioinjector-audio", -+ .name = "audioinjector-stereo", - .owner = THIS_MODULE, - .of_match_table = audioinjector_pi_soundcard_of_match, - }, - -From 393c2e823828b6bf72e97ba1fa406eed2f2c3db6 Mon Sep 17 00:00:00 2001 -From: Matt Flax -Date: Tue, 4 Apr 2017 19:23:04 +1000 -Subject: [PATCH 143/199] Audioinjector octo : Make the playback and capture - symmetric - -This patch ensures that the sample rate and channel count of the audioinjector -octo sound card are symmetric. ---- - sound/soc/bcm/audioinjector-octo-soundcard.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/sound/soc/bcm/audioinjector-octo-soundcard.c b/sound/soc/bcm/audioinjector-octo-soundcard.c -index 49115c8e20ce1a2ba5a99feb8983a1cafb052ca2..5e79f4eff93a21ed3495c77a90f73525695cb3d5 100644 ---- a/sound/soc/bcm/audioinjector-octo-soundcard.c -+++ b/sound/soc/bcm/audioinjector-octo-soundcard.c -@@ -204,6 +204,8 @@ static struct snd_soc_dai_link audioinjector_octo_dai[] = { - .codec_dai_name = "cs42448", - .ops = &audioinjector_octo_ops, - .init = audioinjector_octo_dai_init, -+ .symmetric_rates = 1, -+ .symmetric_channels = 1, - }, - }; - - -From 5b1e8621f88fa6372610b7fbf723bf195fab00fc Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Sun, 23 Apr 2017 19:36:53 +0100 -Subject: [PATCH 144/199] BCM270X_DT: Add bme280 and bmp180 to i2c-sensor - overlay - -Signed-off-by: Phil Elwell ---- - arch/arm/boot/dts/overlays/README | 11 +++++++++-- - arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts | 15 +++++++++++++++ - 2 files changed, 24 insertions(+), 2 deletions(-) - -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index 499cd1920fd373702cfbc9f6e0fcaebca8a47cfc..d32a31cbf4a4382ddfc1b38018ef3ff0ff445145 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -652,9 +652,16 @@ Name: i2c-sensor - Info: Adds support for a number of I2C barometric pressure and temperature - sensors on i2c_arm - Load: dtoverlay=i2c-sensor,= --Params: bmp085 Select the Bosch sensortronic BMP085 -+Params: addr Set the address for the BME280 and BMP280 (0x76 -+ or 0x77 - default 0x76) - -- bmp280 Select the Bosch sensortronic BMP280 -+ bme280 Select the Bosch Sensortronic BME280 -+ -+ bmp085 Select the Bosch Sensortronic BMP085 -+ -+ bmp180 Select the Bosch Sensortronic BMP180 -+ -+ bmp280 Select the Bosch Sensortronic BMP280 - - lm75 Select the Maxim LM75 temperature sensor - -diff --git a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -index 606b2d5012abf2e85712be631c42ea40a0b512c5..e23e34b32a0a8927c14203d7384e800878627347 100644 ---- a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -+++ b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -@@ -12,6 +12,12 @@ - #size-cells = <0>; - status = "okay"; - -+ bme280: bme280@76 { -+ compatible = "bosch,bme280"; -+ reg = <0x76>; -+ status = "disable"; -+ }; -+ - bmp085: bmp085@77 { - compatible = "bosch,bmp085"; - reg = <0x77>; -@@ -19,6 +25,12 @@ - status = "disable"; - }; - -+ bmp180: bmp180@77 { -+ compatible = "bosch,bmp180"; -+ reg = <0x77>; -+ status = "disable"; -+ }; -+ - bmp280: bmp280@76 { - compatible = "bosch,bmp280"; - reg = <0x76>; -@@ -40,7 +52,10 @@ - }; - - __overrides__ { -+ addr = <&bme280>,"reg:0", <&bmp280>,"reg:0"; -+ bme280 = <&bme280>,"status"; - bmp085 = <&bmp085>,"status"; -+ bmp180 = <&bmp180>,"status"; - bmp280 = <&bmp280>,"status"; - lm75 = <&lm75>,"status"; - lm75addr = <&lm75>,"reg:0"; - -From 837e2bea658bf521059f5a28b39a161aeb7087eb Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Sun, 23 Apr 2017 19:38:06 +0100 -Subject: [PATCH 145/199] config: Add CONFIG_BMP280 (and CONFIG_BMP280_I2C) - -Signed-off-by: Phil Elwell ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index 95da3daaf33c7cfab76f6af397e058e9ed8d998f..c86d93a0b103cf812f502088f31ec222f4dea90a 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -1170,6 +1170,7 @@ CONFIG_MCP320X=m - CONFIG_MCP3422=m - CONFIG_DHT11=m - CONFIG_HTU21=m -+CONFIG_BMP280=m - CONFIG_PWM_BCM2835=m - CONFIG_PWM_PCA9685=m - CONFIG_RASPBERRYPI_FIRMWARE=y -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 06d0520e332f21afaa27ac112c0eee6c36a9a9df..515f335d2a638de60d07a45df19ce52a7579f9ca 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -1176,6 +1176,7 @@ CONFIG_MCP320X=m - CONFIG_MCP3422=m - CONFIG_DHT11=m - CONFIG_HTU21=m -+CONFIG_BMP280=m - CONFIG_PWM_BCM2835=m - CONFIG_PWM_PCA9685=m - CONFIG_RASPBERRYPI_FIRMWARE=y - -From b816acaa0d8fb53924639b6de9e59226b0044fc9 Mon Sep 17 00:00:00 2001 -From: Scott Ellis -Date: Tue, 25 Apr 2017 10:46:09 -0400 -Subject: [PATCH 146/199] config: Enable TI TMP102 temp sensor module - -Signed-off-by: Scott Ellis ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index c86d93a0b103cf812f502088f31ec222f4dea90a..5f5830fb19c497895c3e6d6e3a47e961fc84e09a 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -659,6 +659,7 @@ CONFIG_SENSORS_SHT21=m - CONFIG_SENSORS_SHTC1=m - CONFIG_SENSORS_ADS1015=m - CONFIG_SENSORS_INA2XX=m -+CONFIG_SENSORS_TMP102=m - CONFIG_THERMAL=y - CONFIG_BCM2835_THERMAL=y - CONFIG_WATCHDOG=y -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 515f335d2a638de60d07a45df19ce52a7579f9ca..bfda35e4c4bce99b5125eab80f97c73a159de969 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -652,6 +652,7 @@ CONFIG_SENSORS_SHT21=m - CONFIG_SENSORS_SHTC1=m - CONFIG_SENSORS_ADS1015=m - CONFIG_SENSORS_INA2XX=m -+CONFIG_SENSORS_TMP102=m - CONFIG_THERMAL=y - CONFIG_BCM2835_THERMAL=y - CONFIG_WATCHDOG=y - -From 71b830eabd648fde8ac9cf14158c667612fdd536 Mon Sep 17 00:00:00 2001 -From: Scott Ellis -Date: Tue, 25 Apr 2017 13:05:42 -0400 -Subject: [PATCH 147/199] BCM270X_DT: Add tmp102 to i2c sensor overlay - -Signed-off-by: Scott Ellis ---- - arch/arm/boot/dts/overlays/README | 9 +++++++-- - arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts | 11 +++++++++-- - 2 files changed, 16 insertions(+), 4 deletions(-) - -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index d32a31cbf4a4382ddfc1b38018ef3ff0ff445145..4171208933e675a5a3a7e17f8b15447f30a11887 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -652,16 +652,18 @@ Name: i2c-sensor - Info: Adds support for a number of I2C barometric pressure and temperature - sensors on i2c_arm - Load: dtoverlay=i2c-sensor,= --Params: addr Set the address for the BME280 and BMP280 (0x76 -- or 0x77 - default 0x76) -+Params: addr Set the address for the BME280, BMP280 or -+ TMP102 - - bme280 Select the Bosch Sensortronic BME280 -+ Valid addresses 0x76-0x77, default 0x76 - - bmp085 Select the Bosch Sensortronic BMP085 - - bmp180 Select the Bosch Sensortronic BMP180 - - bmp280 Select the Bosch Sensortronic BMP280 -+ Valid addresses 0x76-0x77, default 0x76 - - lm75 Select the Maxim LM75 temperature sensor - -@@ -671,6 +673,9 @@ Params: addr Set the address for the BME280 and BMP280 (0x76 - si7020 Select the Silicon Labs Si7013/20/21 humidity/ - temperature sensor - -+ tmp102 Select the Texas Instruments TMP102 temp sensor -+ Valid addresses 0x48-0x4b, default 0x48 -+ - - Name: i2c0-bcm2708 - Info: Enable the i2c_bcm2708 driver for the i2c0 bus. Not all pin combinations -diff --git a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -index e23e34b32a0a8927c14203d7384e800878627347..e86a13f92c3f75c14fa4425cdfb081d6795ff76a 100644 ---- a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -+++ b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -@@ -1,4 +1,4 @@ --// Definitions for I2C based sensors using the Industrial IO interface. -+// Definitions for I2C based sensors using the Industrial IO or HWMON interface. - /dts-v1/; - /plugin/; - -@@ -48,11 +48,17 @@ - reg = <0x40>; - status = "disable"; - }; -+ -+ tmp102: tmp102@48 { -+ compatible = "ti,tmp102"; -+ reg = <0x48>; -+ status = "disable"; -+ }; - }; - }; - - __overrides__ { -- addr = <&bme280>,"reg:0", <&bmp280>,"reg:0"; -+ addr = <&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0"; - bme280 = <&bme280>,"status"; - bmp085 = <&bmp085>,"status"; - bmp180 = <&bmp180>,"status"; -@@ -60,5 +66,6 @@ - lm75 = <&lm75>,"status"; - lm75addr = <&lm75>,"reg:0"; - si7020 = <&si7020>,"status"; -+ tmp102 = <&tmp102>,"status"; - }; - }; - -From 9cf926a180a5c1e2ddef1e012a3a6382eb0e6def Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Mon, 8 May 2017 16:43:40 +0100 -Subject: [PATCH 148/199] irq_bcm2836: Send event when onlining sleeping cores - -In order to reduce power consumption and bus traffic, it is sensible -for secondary cores to enter a low-power idle state when waiting to -be started. The wfe instruction causes a core to wait until an event -or interrupt arrives before continuing to the next instruction. -The sev instruction sends a wakeup event to the other cores, so call -it from bcm2836_smp_boot_secondary, the function that wakes up the -waiting cores during booting. - -It is harmless to use this patch without the corresponding change -adding wfe to the ARMv7/ARMv8-32 stubs, but if the stubs are updated -and this patch is not applied then the other cores will sleep forever. - -See: https://github.com/raspberrypi/linux/issues/1989 - -Signed-off-by: Phil Elwell ---- - drivers/irqchip/irq-bcm2836.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/drivers/irqchip/irq-bcm2836.c b/drivers/irqchip/irq-bcm2836.c -index 9a7ee04ee0d9b7aa734cf3159ed59c19a338de0d..014f13f89eb896f5cfc75ed9891787d0490baa4b 100644 ---- a/drivers/irqchip/irq-bcm2836.c -+++ b/drivers/irqchip/irq-bcm2836.c -@@ -248,6 +248,9 @@ static int __init bcm2836_smp_boot_secondary(unsigned int cpu, - writel(secondary_startup_phys, - intc.base + LOCAL_MAILBOX3_SET0 + 16 * cpu); - -+ dsb(sy); /* Ensure write has completed before waking the other CPUs */ -+ sev(); -+ - return 0; - } - - -From c1f656b7faa555665af9946bf3e586a66258213e Mon Sep 17 00:00:00 2001 -From: Ahmet Inan -Date: Mon, 15 May 2017 17:10:53 +0200 -Subject: [PATCH 149/199] overlays: Add Goodix overlay - -Add support for I2C connected Goodix gt9271 multiple touch controller using -GPIOs 4 and 17 (pins 7 and 11 on GPIO header) for interrupt and reset. - -Signed-off-by: Ahmet Inan ---- - arch/arm/boot/dts/overlays/Makefile | 1 + - arch/arm/boot/dts/overlays/README | 8 +++++ - arch/arm/boot/dts/overlays/goodix-overlay.dts | 46 +++++++++++++++++++++++++++ - 3 files changed, 55 insertions(+) - create mode 100644 arch/arm/boot/dts/overlays/goodix-overlay.dts - -diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile -index e0ff5793f124fce73732e175bfca424f0a97b632..ddf431837b619f99beb8df45a2714c112e02273c 100644 ---- a/arch/arm/boot/dts/overlays/Makefile -+++ b/arch/arm/boot/dts/overlays/Makefile -@@ -25,6 +25,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ - enc28j60.dtbo \ - enc28j60-spi2.dtbo \ - fe-pi-audio.dtbo \ -+ goodix.dtbo \ - googlevoicehat-soundcard.dtbo \ - gpio-ir.dtbo \ - gpio-poweroff.dtbo \ -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index 4171208933e675a5a3a7e17f8b15447f30a11887..dc391ac88f738c9a711b01a87561c94733745457 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -459,6 +459,14 @@ Load: dtoverlay=fe-pi-audio - Params: - - -+Name: goodix -+Info: Enables I2C connected Goodix gt9271 multiple touch controller using -+ GPIOs 4 and 17 (pins 7 and 11 on GPIO header) for interrupt and reset. -+Load: dtoverlay=goodix,= -+Params: interrupt GPIO used for interrupt (default 4) -+ reset GPIO used for reset (default 17) -+ -+ - Name: googlevoicehat-soundcard - Info: Configures the Google voiceHAT soundcard - Load: dtoverlay=googlevoicehat-soundcard -diff --git a/arch/arm/boot/dts/overlays/goodix-overlay.dts b/arch/arm/boot/dts/overlays/goodix-overlay.dts -new file mode 100644 -index 0000000000000000000000000000000000000000..084f74042ed6379ebd9281374d5391a7e23a431e ---- /dev/null -+++ b/arch/arm/boot/dts/overlays/goodix-overlay.dts -@@ -0,0 +1,46 @@ -+// Device tree overlay for I2C connected Goodix gt9271 multiple touch controller -+/dts-v1/; -+/plugin/; -+ -+/ { -+ compatible = "brcm,bcm2708"; -+ -+ fragment@0 { -+ target = <&gpio>; -+ __overlay__ { -+ goodix_pins: goodix_pins { -+ brcm,pins = <4 17>; // interrupt and reset -+ brcm,function = <0 0>; // in -+ brcm,pull = <2 2>; // pull-up -+ }; -+ }; -+ }; -+ -+ fragment@1 { -+ target = <&i2c1>; -+ __overlay__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ gt9271: gt9271@14 { -+ compatible = "goodix,gt9271"; -+ reg = <0x14>; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&goodix_pins>; -+ interrupt-parent = <&gpio>; -+ interrupts = <4 2>; // high-to-low edge triggered -+ irq-gpios = <&gpio 4 0>; // Pin7 on GPIO header -+ reset-gpios = <&gpio 17 0>; // Pin11 on GPIO header -+ }; -+ }; -+ }; -+ -+ __overrides__ { -+ interrupt = <&goodix_pins>,"brcm,pins:0", -+ <>9271>,"interrupts:0", -+ <>9271>,"irq-gpios:4"; -+ reset = <&goodix_pins>,"brcm,pins:4", -+ <>9271>,"reset-gpios:4"; -+ }; -+}; - -From 7af08623c8ef0a98da5490a87d9cc1e3b4867614 Mon Sep 17 00:00:00 2001 -From: chenzhiwo -Date: Wed, 17 May 2017 16:34:57 +0800 -Subject: [PATCH 150/199] Add device tree overlay for GPIO connected rotary - encoder. See Documentation/input/rotary-encoder.txt for more information. - ---- - arch/arm/boot/dts/overlays/Makefile | 1 + - arch/arm/boot/dts/overlays/README | 9 +++++ - .../boot/dts/overlays/rotary-encoder-overlay.dts | 43 ++++++++++++++++++++++ - 3 files changed, 53 insertions(+) - create mode 100644 arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts - -diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile -index ddf431837b619f99beb8df45a2714c112e02273c..6853e3575f001522a402e7eb31933d32fbac581d 100644 ---- a/arch/arm/boot/dts/overlays/Makefile -+++ b/arch/arm/boot/dts/overlays/Makefile -@@ -76,6 +76,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ - pwm-2chan.dtbo \ - qca7000.dtbo \ - raspidac3.dtbo \ -+ rotary-encoder.dtbo \ - rpi-backlight.dtbo \ - rpi-cirrus-wm5102.dtbo \ - rpi-dac.dtbo \ -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index dc391ac88f738c9a711b01a87561c94733745457..f7e11387e535ce2dba8272798a023963315685b6 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -1122,6 +1122,15 @@ Load: dtoverlay=raspidac3 - Params: - - -+Name: rotary-encoder -+Info: Overlay for GPIO connected rotary encoder. -+Load: dtoverlay=rotary-encoder,= -+Params: rotary0_pin_a GPIO connected to rotary encoder channel A -+ (default 4). -+ rotary0_pin_b GPIO connected to rotary encoder channel B -+ (default 17). -+ -+ - Name: rpi-backlight - Info: Raspberry Pi official display backlight driver - Load: dtoverlay=rpi-backlight -diff --git a/arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts b/arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts -new file mode 100644 -index 0000000000000000000000000000000000000000..c0c6bccff60cc15d9a9bf59d2c7cba41eb9c1cdc ---- /dev/null -+++ b/arch/arm/boot/dts/overlays/rotary-encoder-overlay.dts -@@ -0,0 +1,43 @@ -+// Device tree overlay for GPIO connected rotary encoder. -+/dts-v1/; -+/plugin/; -+ -+/ { -+ compatible = "brcm,bcm2708"; -+ -+ fragment@0 { -+ target = <&gpio>; -+ __overlay__ { -+ rotary0_pins: rotary0_pins { -+ brcm,pins = <4 17>; /* gpio 4 17 */ -+ brcm,function = <0 0>; /* input */ -+ brcm,pull = <2 2>; /* pull-up */ -+ }; -+ -+ }; -+ }; -+ -+ fragment@1 { -+ target-path = "/"; -+ __overlay__ { -+ rotary0: rotary@0 { -+ compatible = "rotary-encoder"; -+ status = "okay"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&rotary0_pins>; -+ gpios = <&gpio 4 0>, <&gpio 17 0>; -+ linux,axis = <0>; /* REL_X */ -+ rotary-encoder,encoding = "gray"; -+ rotary-encoder,relative-axis; -+ }; -+ }; -+ -+ }; -+ -+ __overrides__ { -+ rotary0_pin_a = <&rotary0>,"gpios:4", -+ <&rotary0_pins>,"brcm,pins:0"; -+ rotary0_pin_b = <&rotary0>,"gpios:16", -+ <&rotary0_pins>,"brcm,pins:4"; -+ }; -+}; - -From 76196f40dbed74eac9240e52c4d91498442ea5c1 Mon Sep 17 00:00:00 2001 -From: Anton Onishchenko -Date: Tue, 23 May 2017 18:55:46 +0300 -Subject: [PATCH 151/199] mpu6050 device tree overlay (#2031) - -Add overlay and config options for InvenSense MPU6050 6-axis motion -detector. ---- - arch/arm/boot/dts/overlays/Makefile | 1 + - arch/arm/boot/dts/overlays/README | 6 ++++++ - arch/arm/boot/dts/overlays/mpu6050-overlay.dts | 28 ++++++++++++++++++++++++++ - arch/arm/configs/bcm2709_defconfig | 3 +-- - arch/arm/configs/bcmrpi_defconfig | 3 +-- - 5 files changed, 37 insertions(+), 4 deletions(-) - create mode 100644 arch/arm/boot/dts/overlays/mpu6050-overlay.dts - -diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile -index 6853e3575f001522a402e7eb31933d32fbac581d..c95b37f0a4c72160421f44819c5f29246d3352f9 100644 ---- a/arch/arm/boot/dts/overlays/Makefile -+++ b/arch/arm/boot/dts/overlays/Makefile -@@ -59,6 +59,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ - midi-uart0.dtbo \ - midi-uart1.dtbo \ - mmc.dtbo \ -+ mpu6050.dtbo \ - mz61581.dtbo \ - pi3-act-led.dtbo \ - pi3-disable-bt.dtbo \ -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index f7e11387e535ce2dba8272798a023963315685b6..d560490c2661c3396d37315bbb9b2d9e93b5ac15 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -898,6 +898,12 @@ Params: overclock_50 Clock (in MHz) to use when the MMC framework - requests 50MHz - - -+Name: mpu6050 -+Info: Overlay for i2c connected mpu6050 imu -+Load: dtoverlay=mpu6050,= -+Params: interrupt GPIO pin for interrupt (default 4) -+ -+ - Name: mz61581 - Info: MZ61581 display by Tontec - Load: dtoverlay=mz61581,= -diff --git a/arch/arm/boot/dts/overlays/mpu6050-overlay.dts b/arch/arm/boot/dts/overlays/mpu6050-overlay.dts -new file mode 100644 -index 0000000000000000000000000000000000000000..06037969c3abba270b3cad45875342f3c730506e ---- /dev/null -+++ b/arch/arm/boot/dts/overlays/mpu6050-overlay.dts -@@ -0,0 +1,28 @@ -+// Definitions for MPU6050 -+/dts-v1/; -+/plugin/; -+ -+/ { -+ compatible = "brcm,bcm2708"; -+ -+ fragment@0 { -+ target = <&i2c1>; -+ __overlay__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ clock-frequency = <400000>; -+ -+ mpu6050: mpu6050@68 { -+ compatible = "invensense,mpu6050"; -+ reg = <0x68>; -+ interrupt-parent = <&gpio>; -+ interrupts = <4 1>; -+ }; -+ }; -+ }; -+ -+ __overrides__ { -+ interrupt = <&mpu6050>,"interrupts:0"; -+ }; -+}; -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index 5f5830fb19c497895c3e6d6e3a47e961fc84e09a..b310e13042b20c709a8139d0b3973c3ed5f283cf 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -1164,13 +1164,12 @@ CONFIG_RASPBERRYPI_POWER=y - CONFIG_EXTCON=m - CONFIG_EXTCON_ARIZONA=m - CONFIG_IIO=m --CONFIG_IIO_BUFFER=y - CONFIG_IIO_BUFFER_CB=m --CONFIG_IIO_KFIFO_BUF=m - CONFIG_MCP320X=m - CONFIG_MCP3422=m - CONFIG_DHT11=m - CONFIG_HTU21=m -+CONFIG_INV_MPU6050_I2C=m - CONFIG_BMP280=m - CONFIG_PWM_BCM2835=m - CONFIG_PWM_PCA9685=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index bfda35e4c4bce99b5125eab80f97c73a159de969..a9841b71a4b633a81392c533578845d62f6aa78f 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -1170,13 +1170,12 @@ CONFIG_RASPBERRYPI_POWER=y - CONFIG_EXTCON=m - CONFIG_EXTCON_ARIZONA=m - CONFIG_IIO=m --CONFIG_IIO_BUFFER=y - CONFIG_IIO_BUFFER_CB=m --CONFIG_IIO_KFIFO_BUF=m - CONFIG_MCP320X=m - CONFIG_MCP3422=m - CONFIG_DHT11=m - CONFIG_HTU21=m -+CONFIG_INV_MPU6050_I2C=m - CONFIG_BMP280=m - CONFIG_PWM_BCM2835=m - CONFIG_PWM_PCA9685=m - -From c97964c91a2bceeb94bdb8f63edf39ef67194808 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Wed, 31 May 2017 09:33:55 +0100 -Subject: [PATCH 152/199] config: Adding SENSOR_JC42 - -The jc42 module supports a number of I2C-based temperature -sensor modules. - -[ DM_RAID0 config lost because now selected by DM_RAID ] - -See: https://github.com/raspberrypi/linux/issues/2046 - -Signed-off-by: Phil Elwell ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index b310e13042b20c709a8139d0b3973c3ed5f283cf..00845b52952479976b4fdfdc94a16a366d82ae7d 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -654,6 +654,7 @@ CONFIG_POWER_RESET=y - CONFIG_POWER_RESET_GPIO=y - CONFIG_BATTERY_DS2760=m - CONFIG_HWMON=m -+CONFIG_SENSORS_JC42=m - CONFIG_SENSORS_LM75=m - CONFIG_SENSORS_SHT21=m - CONFIG_SENSORS_SHTC1=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index a9841b71a4b633a81392c533578845d62f6aa78f..2ba46a28c2e7b21a401cc3544353937eca44218d 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -647,6 +647,7 @@ CONFIG_POWER_RESET=y - CONFIG_POWER_RESET_GPIO=y - CONFIG_BATTERY_DS2760=m - CONFIG_HWMON=m -+CONFIG_SENSORS_JC42=m - CONFIG_SENSORS_LM75=m - CONFIG_SENSORS_SHT21=m - CONFIG_SENSORS_SHTC1=m - -From 3867f9c70395cfc2c33b0b7a23d80d64a5589b47 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Wed, 31 May 2017 15:27:39 +0100 -Subject: [PATCH 153/199] BCM270X_DT: Improve i2c-sensor and i2c-rtc overlay - -Use the "__dormant__" feature to permit multiple instances of each -overlay, which is more useful now that changing the "reg" property -also changes the node address. Although the overlay grows slightly, -when applied only the requested node is included. - -Usage does not change, except that the "lm75addr" parameter of the -i2c-sensor overlay has been deprecated in favour of the generic -"addr" parameter. - -Signed-off-by: Phil Elwell ---- - arch/arm/boot/dts/overlays/README | 8 +- - arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts | 127 ++++++++++++++++++---- - arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts | 87 ++++++++++++--- - 3 files changed, 179 insertions(+), 43 deletions(-) - -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index d560490c2661c3396d37315bbb9b2d9e93b5ac15..ce8706a8aa88c36b0dee95c56ee58b4a524b8b43 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -660,8 +660,8 @@ Name: i2c-sensor - Info: Adds support for a number of I2C barometric pressure and temperature - sensors on i2c_arm - Load: dtoverlay=i2c-sensor,= --Params: addr Set the address for the BME280, BMP280 or -- TMP102 -+Params: addr Set the address for the BME280, BMP280, TMP102 -+ or LM75 - - bme280 Select the Bosch Sensortronic BME280 - Valid addresses 0x76-0x77, default 0x76 -@@ -674,9 +674,9 @@ Params: addr Set the address for the BME280, BMP280 or - Valid addresses 0x76-0x77, default 0x76 - - lm75 Select the Maxim LM75 temperature sensor -+ Valid addresses 0x48-0x4f, default 0x4f - -- lm75addr Choose the address for the LM75 (0x48-0x4f - -- default 0x4f) -+ lm75addr Deprecated - use addr parameter instead - - si7020 Select the Silicon Labs Si7013/20/21 humidity/ - temperature sensor -diff --git a/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts b/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts -index 1efcf0b712c9c5c19210545002ac1f0931db58f5..6140f172a86b8731782f938f76cb5dac9f28b662 100644 ---- a/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts -+++ b/arch/arm/boot/dts/overlays/i2c-rtc-overlay.dts -@@ -7,7 +7,7 @@ - - fragment@0 { - target = <&i2c_arm>; -- __overlay__ { -+ __dormant__ { - #address-cells = <1>; - #size-cells = <0>; - status = "okay"; -@@ -17,61 +17,142 @@ - reg = <0x69>; - abracon,tc-diode = "standard"; - abracon,tc-resistor = <0>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@1 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ - ds1307: ds1307@68 { - compatible = "maxim,ds1307"; - reg = <0x68>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@2 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ - ds1339: ds1339@68 { - compatible = "dallas,ds1339"; - trickle-resistor-ohms = <0>; - reg = <0x68>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@3 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ ds3231: ds3231@68 { -+ compatible = "maxim,ds3231"; -+ reg = <0x68>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@4 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ - mcp7940x: mcp7940x@6f { - compatible = "microchip,mcp7940x"; - reg = <0x6f>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@5 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ - mcp7941x: mcp7941x@6f { - compatible = "microchip,mcp7941x"; - reg = <0x6f>; -- status = "disable"; -- }; -- ds3231: ds3231@68 { -- compatible = "maxim,ds3231"; -- reg = <0x68>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@6 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ - pcf2127: pcf2127@51 { - compatible = "nxp,pcf2127"; - reg = <0x51>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@7 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ - pcf8523: pcf8523@68 { - compatible = "nxp,pcf8523"; - reg = <0x68>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@8 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ - pcf8563: pcf8563@51 { - compatible = "nxp,pcf8563"; - reg = <0x51>; -- status = "disable"; -+ status = "okay"; - }; - }; - }; -+ - __overrides__ { -- abx80x = <&abx80x>,"status"; -- ds1307 = <&ds1307>,"status"; -- ds1339 = <&ds1339>,"status"; -- ds3231 = <&ds3231>,"status"; -- mcp7940x = <&mcp7940x>,"status"; -- mcp7941x = <&mcp7941x>,"status"; -- pcf2127 = <&pcf2127>,"status"; -- pcf8523 = <&pcf8523>,"status"; -- pcf8563 = <&pcf8563>,"status"; -+ abx80x = <0>,"+0"; -+ ds1307 = <0>,"+1"; -+ ds1339 = <0>,"+2"; -+ ds3231 = <0>,"+3"; -+ mcp7940x = <0>,"+4"; -+ mcp7941x = <0>,"+5"; -+ pcf2127 = <0>,"+6"; -+ pcf8523 = <0>,"+7"; -+ pcf8563 = <0>,"+8"; - trickle-diode-type = <&abx80x>,"abracon,tc-diode"; - trickle-resistor-ohms = <&ds1339>,"trickle-resistor-ohms:0", - <&abx80x>,"abracon,tc-resistor"; -diff --git a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -index e86a13f92c3f75c14fa4425cdfb081d6795ff76a..d2f0008addfadac8f6ed774a6e4f3f97871c0d61 100644 ---- a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -+++ b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -@@ -7,7 +7,7 @@ - - fragment@0 { - target = <&i2c_arm>; -- __overlay__ { -+ __dormant__ { - #address-cells = <1>; - #size-cells = <0>; - status = "okay"; -@@ -15,57 +15,112 @@ - bme280: bme280@76 { - compatible = "bosch,bme280"; - reg = <0x76>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@1 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; - - bmp085: bmp085@77 { - compatible = "bosch,bmp085"; - reg = <0x77>; - default-oversampling = <3>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@2 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; - - bmp180: bmp180@77 { - compatible = "bosch,bmp180"; - reg = <0x77>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@3 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; - - bmp280: bmp280@76 { - compatible = "bosch,bmp280"; - reg = <0x76>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@4 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; - - lm75: lm75@4f { - compatible = "lm75"; - reg = <0x4f>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@5 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; - - si7020: si7020@40 { - compatible = "si7020"; - reg = <0x40>; -- status = "disable"; -+ status = "okay"; - }; -+ }; -+ }; -+ -+ fragment@6 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; - - tmp102: tmp102@48 { - compatible = "ti,tmp102"; - reg = <0x48>; -- status = "disable"; -+ status = "okay"; - }; - }; - }; - - __overrides__ { -- addr = <&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0"; -- bme280 = <&bme280>,"status"; -- bmp085 = <&bmp085>,"status"; -- bmp180 = <&bmp180>,"status"; -- bmp280 = <&bmp280>,"status"; -- lm75 = <&lm75>,"status"; -+ addr = <&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0", -+ <&lm75>,"reg:0"; -+ bme280 = <0>,"+0"; -+ bmp085 = <0>,"+1"; -+ bmp180 = <0>,"+2"; -+ bmp280 = <0>,"+3"; -+ lm75 = <0>,"+4"; - lm75addr = <&lm75>,"reg:0"; -- si7020 = <&si7020>,"status"; -- tmp102 = <&tmp102>,"status"; -+ si7020 = <0>,"+5"; -+ tmp102 = <0>,"+6"; - }; - }; - -From 1c7571813a26ad03b886f2b0bf411f08a9892ac7 Mon Sep 17 00:00:00 2001 -From: Stefan Tatschner -Date: Mon, 29 May 2017 21:46:16 +0200 -Subject: [PATCH 154/199] Add device tree config for htu21 - -See: https://github.com/raspberrypi/linux/pull/2041 - -Signed-off-by: Phil Elwell ---- - arch/arm/boot/dts/overlays/README | 2 ++ - arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts | 26 ++++++++++++++++++----- - 2 files changed, 23 insertions(+), 5 deletions(-) - -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index ce8706a8aa88c36b0dee95c56ee58b4a524b8b43..bce02c82f3438995e5a74080876391f758bfe27b 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -673,6 +673,8 @@ Params: addr Set the address for the BME280, BMP280, TMP102 - bmp280 Select the Bosch Sensortronic BMP280 - Valid addresses 0x76-0x77, default 0x76 - -+ htu21 Select the HTU21 temperature and humidity sensor -+ - lm75 Select the Maxim LM75 temperature sensor - Valid addresses 0x48-0x4f, default 0x4f - -diff --git a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -index d2f0008addfadac8f6ed774a6e4f3f97871c0d61..17c27e3b666a7a83619471b50c63bb93836653c5 100644 ---- a/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -+++ b/arch/arm/boot/dts/overlays/i2c-sensor-overlay.dts -@@ -73,6 +73,21 @@ - #size-cells = <0>; - status = "okay"; - -+ htu21: htu21@40 { -+ compatible = "htu21"; -+ reg = <0x40>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@5 { -+ target = <&i2c_arm>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ - lm75: lm75@4f { - compatible = "lm75"; - reg = <0x4f>; -@@ -81,7 +96,7 @@ - }; - }; - -- fragment@5 { -+ fragment@6 { - target = <&i2c_arm>; - __dormant__ { - #address-cells = <1>; -@@ -96,7 +111,7 @@ - }; - }; - -- fragment@6 { -+ fragment@7 { - target = <&i2c_arm>; - __dormant__ { - #address-cells = <1>; -@@ -118,9 +133,10 @@ - bmp085 = <0>,"+1"; - bmp180 = <0>,"+2"; - bmp280 = <0>,"+3"; -- lm75 = <0>,"+4"; -+ htu21 = <0>,"+4"; -+ lm75 = <0>,"+5"; - lm75addr = <&lm75>,"reg:0"; -- si7020 = <0>,"+5"; -- tmp102 = <0>,"+6"; -+ si7020 = <0>,"+6"; -+ tmp102 = <0>,"+7"; - }; - }; - -From 7f73bc13baca73c1428385dcfbdb72deffdac09f Mon Sep 17 00:00:00 2001 -From: sandeepal -Date: Fri, 2 Jun 2017 18:59:46 +0530 -Subject: [PATCH 155/199] Allo Digione Driver (#2048) - -Driver for the Allo Digione soundcard ---- - arch/arm/boot/dts/overlays/Makefile | 1 + - arch/arm/boot/dts/overlays/README | 6 + - .../arm/boot/dts/overlays/allo-digione-overlay.dts | 44 ++++ - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - sound/soc/bcm/Kconfig | 7 + - sound/soc/bcm/Makefile | 2 + - sound/soc/bcm/allo-digione.c | 268 +++++++++++++++++++++ - 8 files changed, 330 insertions(+) - create mode 100644 arch/arm/boot/dts/overlays/allo-digione-overlay.dts - create mode 100644 sound/soc/bcm/allo-digione.c - -diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile -index c95b37f0a4c72160421f44819c5f29246d3352f9..eca81982c0f19988abd05165fc62a80d26f539cb 100644 ---- a/arch/arm/boot/dts/overlays/Makefile -+++ b/arch/arm/boot/dts/overlays/Makefile -@@ -8,6 +8,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ - ads7846.dtbo \ - akkordion-iqdacplus.dtbo \ - allo-boss-dac-pcm512x-audio.dtbo \ -+ allo-digione.dtbo \ - allo-piano-dac-pcm512x-audio.dtbo \ - allo-piano-dac-plus-pcm512x-audio.dtbo \ - at86rf233.dtbo \ -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index bce02c82f3438995e5a74080876391f758bfe27b..19df6883be4277240283d5f63f27e34a22a2eec5 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -287,6 +287,12 @@ Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec - slave" - - -+Name: allo-digione -+Info: Configures the Allo Digione audio card -+Load: dtoverlay=allo-digione -+Params: -+ -+ - Name: allo-piano-dac-pcm512x-audio - Info: Configures the Allo Piano DAC (2.0/2.1) audio cards. - (NB. This initial support is for 2.0 channel audio ONLY! ie. stereo. -diff --git a/arch/arm/boot/dts/overlays/allo-digione-overlay.dts b/arch/arm/boot/dts/overlays/allo-digione-overlay.dts -new file mode 100644 -index 0000000000000000000000000000000000000000..101277a11a24e9b3eb441c44c3f19c61836fe77c ---- /dev/null -+++ b/arch/arm/boot/dts/overlays/allo-digione-overlay.dts -@@ -0,0 +1,44 @@ -+// Definitions for Allo DigiOne -+/dts-v1/; -+/plugin/; -+ -+/ { -+ compatible = "brcm,bcm2708"; -+ -+ fragment@0 { -+ target = <&i2s>; -+ __overlay__ { -+ status = "okay"; -+ }; -+ }; -+ -+ fragment@1 { -+ target = <&i2c1>; -+ __overlay__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ wm8804@3b { -+ #sound-dai-cells = <0>; -+ compatible = "wlf,wm8804"; -+ reg = <0x3b>; -+ PVDD-supply = <&vdd_3v3_reg>; -+ DVDD-supply = <&vdd_3v3_reg>; -+ status = "okay"; -+ wlf,reset-gpio = <&gpio 17 0>; -+ }; -+ }; -+ }; -+ -+ fragment@2 { -+ target = <&sound>; -+ __overlay__ { -+ compatible = "allo,allo-digione"; -+ i2s-controller = <&i2s>; -+ status = "okay"; -+ clock44-gpio = <&gpio 5 0>; -+ clock48-gpio = <&gpio 6 0>; -+ }; -+ }; -+}; -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index 00845b52952479976b4fdfdc94a16a366d82ae7d..d2838cde4019be5f6faf0a70038c6365df9e6dde 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -892,6 +892,7 @@ CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO_V2=m - CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC=m - CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS=m - CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC=m -+CONFIG_SND_BCM2708_SOC_ALLO_DIGIONE=m - CONFIG_SND_BCM2708_SOC_FE_PI_AUDIO=m - CONFIG_SND_PISOUND=m - CONFIG_SND_SOC_ADAU1701=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 2ba46a28c2e7b21a401cc3544353937eca44218d..efdb0fbc1b07c7b679cb20d8c1270c77d5d3c684 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -885,6 +885,7 @@ CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO_V2=m - CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC=m - CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS=m - CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC=m -+CONFIG_SND_BCM2708_SOC_ALLO_DIGIONE=m - CONFIG_SND_BCM2708_SOC_FE_PI_AUDIO=m - CONFIG_SND_PISOUND=m - CONFIG_SND_SOC_ADAU1701=m -diff --git a/sound/soc/bcm/Kconfig b/sound/soc/bcm/Kconfig -index 355bdeb25f81d15593f78df0e87a48404908ca4b..381d32bb9deb3cf2c531e2a4563418cd6eb9d505 100644 ---- a/sound/soc/bcm/Kconfig -+++ b/sound/soc/bcm/Kconfig -@@ -176,6 +176,13 @@ config SND_BCM2708_SOC_ALLO_BOSS_DAC - help - Say Y or M if you want to add support for Allo Boss DAC. - -+config SND_BCM2708_SOC_ALLO_DIGIONE -+ tristate "Support for Allo DigiOne" -+ depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S -+ select SND_SOC_PCM512x_I2C -+ help -+ Say Y or M if you want to add support for Allo DigiOne. -+ - config SND_BCM2708_SOC_FE_PI_AUDIO - tristate "Support for Fe-Pi-Audio" - depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S -diff --git a/sound/soc/bcm/Makefile b/sound/soc/bcm/Makefile -index 72e1620fa4038035804cf3b2a09c6b12e7ae0fe1..53ea8229d7ac2065176983385dd7ba85ee3915ea 100644 ---- a/sound/soc/bcm/Makefile -+++ b/sound/soc/bcm/Makefile -@@ -34,6 +34,7 @@ snd-soc-dionaudio-loco-v2-objs := dionaudio_loco-v2.o - snd-soc-allo-boss-dac-objs := allo-boss-dac.o - snd-soc-allo-piano-dac-objs := allo-piano-dac.o - snd-soc-allo-piano-dac-plus-objs := allo-piano-dac-plus.o -+snd-soc-allo-digione-objs := allo-digione.o - snd-soc-pisound-objs := pisound.o - snd-soc-fe-pi-audio-objs := fe-pi-audio.o - -@@ -60,5 +61,6 @@ obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO_V2) += snd-soc-dionaudio-loco-v2.o - obj-$(CONFIG_SND_BCM2708_SOC_ALLO_BOSS_DAC) += snd-soc-allo-boss-dac.o - obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC) += snd-soc-allo-piano-dac.o - obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC_PLUS) += snd-soc-allo-piano-dac-plus.o -+obj-$(CONFIG_SND_BCM2708_SOC_ALLO_DIGIONE) += snd-soc-allo-digione.o - obj-$(CONFIG_SND_PISOUND) += snd-soc-pisound.o - obj-$(CONFIG_SND_BCM2708_SOC_FE_PI_AUDIO) += snd-soc-fe-pi-audio.o -diff --git a/sound/soc/bcm/allo-digione.c b/sound/soc/bcm/allo-digione.c -new file mode 100644 -index 0000000000000000000000000000000000000000..e3664e44c699d0102120ecf99e8b780a4505ebad ---- /dev/null -+++ b/sound/soc/bcm/allo-digione.c -@@ -0,0 +1,268 @@ -+/* -+ * ASoC Driver for Allo DigiOne -+ * -+ * Author: Baswaraj -+ * Copyright 2017 -+ * based on code by Daniel Matuschek -+ * based on code by Florian Meier -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ */ -+ -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "../codecs/wm8804.h" -+ -+static short int auto_shutdown_output = 0; -+module_param(auto_shutdown_output, short, -+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); -+MODULE_PARM_DESC(auto_shutdown_output, "Shutdown SP/DIF output if playback is stopped"); -+ -+#define CLK_44EN_RATE 22579200UL -+#define CLK_48EN_RATE 24576000UL -+ -+static struct gpio_desc *snd_allo_clk44gpio; -+static struct gpio_desc *snd_allo_clk48gpio; -+ -+static int samplerate = 44100; -+ -+static uint32_t snd_allo_digione_enable_clock(int sample_rate) -+{ -+ switch (sample_rate) { -+ case 11025: -+ case 22050: -+ case 44100: -+ case 88200: -+ case 176400: -+ gpiod_set_value_cansleep(snd_allo_clk44gpio, 1); -+ gpiod_set_value_cansleep(snd_allo_clk48gpio, 0); -+ return CLK_44EN_RATE; -+ default: -+ gpiod_set_value_cansleep(snd_allo_clk48gpio, 1); -+ gpiod_set_value_cansleep(snd_allo_clk44gpio, 0); -+ return CLK_48EN_RATE; -+ } -+} -+ -+ -+static int snd_allo_digione_init(struct snd_soc_pcm_runtime *rtd) -+{ -+ struct snd_soc_codec *codec = rtd->codec; -+ -+ /* enable TX output */ -+ snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x0); -+ -+ return 0; -+} -+ -+static int snd_allo_digione_startup(struct snd_pcm_substream *substream) -+{ -+ /* turn on digital output */ -+ struct snd_soc_pcm_runtime *rtd = substream->private_data; -+ struct snd_soc_codec *codec = rtd->codec; -+ snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x00); -+ return 0; -+} -+ -+static void snd_allo_digione_shutdown(struct snd_pcm_substream *substream) -+{ -+ /* turn off output */ -+ if (auto_shutdown_output) { -+ /* turn off output */ -+ struct snd_soc_pcm_runtime *rtd = substream->private_data; -+ struct snd_soc_codec *codec = rtd->codec; -+ snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x3c); -+ } -+} -+ -+static int snd_allo_digione_hw_params(struct snd_pcm_substream *substream, -+ struct snd_pcm_hw_params *params) -+{ -+ struct snd_soc_pcm_runtime *rtd = substream->private_data; -+ struct snd_soc_dai *codec_dai = rtd->codec_dai; -+ struct snd_soc_codec *codec = rtd->codec; -+ struct snd_soc_dai *cpu_dai = rtd->cpu_dai; -+ -+ int sysclk = 27000000; /* This is fixed on this board */ -+ -+ long mclk_freq = 0; -+ int mclk_div = 1; -+ int sampling_freq = 1; -+ -+ int ret; -+ -+ samplerate = params_rate(params); -+ -+ if (samplerate <= 96000) { -+ mclk_freq = samplerate * 256; -+ mclk_div = WM8804_MCLKDIV_256FS; -+ } else { -+ mclk_freq = samplerate * 128; -+ mclk_div = WM8804_MCLKDIV_128FS; -+ } -+ -+ sysclk = snd_allo_digione_enable_clock(samplerate); -+ -+ switch (samplerate) { -+ case 32000: -+ sampling_freq=0x03; -+ break; -+ case 44100: -+ sampling_freq=0x00; -+ break; -+ case 48000: -+ sampling_freq=0x02; -+ break; -+ case 88200: -+ sampling_freq=0x08; -+ break; -+ case 96000: -+ sampling_freq=0x0a; -+ break; -+ case 176400: -+ sampling_freq=0x0c; -+ break; -+ case 192000: -+ sampling_freq=0x0e; -+ break; -+ default: -+ dev_err(codec->dev, -+ "Failed to set WM8804 SYSCLK, unsupported samplerate %d\n", -+ samplerate); -+ } -+ -+ snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div); -+ snd_soc_dai_set_pll(codec_dai, 0, 0, sysclk, mclk_freq); -+ -+ ret = snd_soc_dai_set_sysclk(codec_dai, WM8804_TX_CLKSRC_PLL, -+ sysclk, SND_SOC_CLOCK_OUT); -+ -+ if (ret < 0) { -+ dev_err(codec->dev, -+ "Failed to set WM8804 SYSCLK: %d\n", ret); -+ return ret; -+ } -+ -+ /* Enable TX output */ -+ snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x0); -+ -+ /* Power on */ -+ snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0); -+ -+ /* set sampling frequency status bits */ -+ snd_soc_update_bits(codec, WM8804_SPDTX4, 0x0f, sampling_freq); -+ -+ return snd_soc_dai_set_bclk_ratio(cpu_dai, 64); -+} -+ -+/* machine stream operations */ -+static struct snd_soc_ops snd_allo_digione_ops = { -+ .hw_params = snd_allo_digione_hw_params, -+ .startup = snd_allo_digione_startup, -+ .shutdown = snd_allo_digione_shutdown, -+}; -+ -+static struct snd_soc_dai_link snd_allo_digione_dai[] = { -+{ -+ .name = "Allo DigiOne", -+ .stream_name = "Allo DigiOne HiFi", -+ .cpu_dai_name = "bcm2708-i2s.0", -+ .codec_dai_name = "wm8804-spdif", -+ .platform_name = "bcm2708-i2s.0", -+ .codec_name = "wm8804.1-003b", -+ .dai_fmt = SND_SOC_DAIFMT_I2S | -+ SND_SOC_DAIFMT_NB_NF | -+ SND_SOC_DAIFMT_CBM_CFM, -+ .ops = &snd_allo_digione_ops, -+ .init = snd_allo_digione_init, -+}, -+}; -+ -+/* audio machine driver */ -+static struct snd_soc_card snd_allo_digione = { -+ .name = "snd_allo_digione", -+ .driver_name = "AlloDigiOne", -+ .owner = THIS_MODULE, -+ .dai_link = snd_allo_digione_dai, -+ .num_links = ARRAY_SIZE(snd_allo_digione_dai), -+}; -+ -+static int snd_allo_digione_probe(struct platform_device *pdev) -+{ -+ int ret = 0; -+ -+ snd_allo_digione.dev = &pdev->dev; -+ -+ if (pdev->dev.of_node) { -+ struct device_node *i2s_node; -+ struct snd_soc_dai_link *dai = &snd_allo_digione_dai[0]; -+ i2s_node = of_parse_phandle(pdev->dev.of_node, -+ "i2s-controller", 0); -+ -+ if (i2s_node) { -+ dai->cpu_dai_name = NULL; -+ dai->cpu_of_node = i2s_node; -+ dai->platform_name = NULL; -+ dai->platform_of_node = i2s_node; -+ } -+ -+ snd_allo_clk44gpio = -+ devm_gpiod_get(&pdev->dev, "clock44", GPIOD_OUT_LOW); -+ if (IS_ERR(snd_allo_clk44gpio)) -+ dev_err(&pdev->dev, "devm_gpiod_get() failed\n"); -+ -+ snd_allo_clk48gpio = -+ devm_gpiod_get(&pdev->dev, "clock48", GPIOD_OUT_LOW); -+ if (IS_ERR(snd_allo_clk48gpio)) -+ dev_err(&pdev->dev, "devm_gpiod_get() failed\n"); -+ } -+ -+ ret = snd_soc_register_card(&snd_allo_digione); -+ if (ret && ret != -EPROBE_DEFER) -+ dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", -+ ret); -+ -+ return ret; -+} -+ -+static int snd_allo_digione_remove(struct platform_device *pdev) -+{ -+ return snd_soc_unregister_card(&snd_allo_digione); -+} -+ -+static const struct of_device_id snd_allo_digione_of_match[] = { -+ { .compatible = "allo,allo-digione", }, -+ {}, -+}; -+MODULE_DEVICE_TABLE(of, snd_allo_digione_of_match); -+ -+static struct platform_driver snd_allo_digione_driver = { -+ .driver = { -+ .name = "snd-allo-digione", -+ .owner = THIS_MODULE, -+ .of_match_table = snd_allo_digione_of_match, -+ }, -+ .probe = snd_allo_digione_probe, -+ .remove = snd_allo_digione_remove, -+}; -+ -+module_platform_driver(snd_allo_digione_driver); -+ -+MODULE_AUTHOR("Baswaraj "); -+MODULE_DESCRIPTION("ASoC Driver for Allo DigiOne"); -+MODULE_LICENSE("GPL v2"); - -From a936a089e96c837040d822eae274739ea46dd323 Mon Sep 17 00:00:00 2001 +From c45671ace023bcf54d977980e66c9ad202bbc3f1 Mon Sep 17 00:00:00 2001 From: Andrei Gherzan Date: Mon, 5 Jun 2017 16:40:38 +0100 -Subject: [PATCH 156/199] dma-bcm2708: Fix module compilation of +Subject: [PATCH 128/129] dma-bcm2708: Fix module compilation of CONFIG_DMA_BCM2708 bcm2708-dmaengine.c defines functions like bcm_dma_start which are @@ -135438,1249 +134701,10 @@ index c5bfff2765be4606077e6c8af73040ec13ee8974..6ca874d332a8bc666b1c9576ac51f479 #endif /* _PLAT_BCM2708_DMA_H */ -From d3b2f6efa2d4f208a401f331e7d1ee1313ee7b32 Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Tue, 20 Jun 2017 17:51:47 +0100 -Subject: [PATCH 157/199] bcm2835-cpufreq: Change licence to GPLv2 - -Signed-off-by: Eben Upton -Signed-off-by: Dom Cobley ---- - drivers/cpufreq/bcm2835-cpufreq.c | 36 ++++++++++++++---------------------- - 1 file changed, 14 insertions(+), 22 deletions(-) - -diff --git a/drivers/cpufreq/bcm2835-cpufreq.c b/drivers/cpufreq/bcm2835-cpufreq.c -index 414fbdc10dfbfc6e4bb47870a7af3fd5780f9c9a..99345969b0e4d651fd9033d67de2febb13fc0892 100644 ---- a/drivers/cpufreq/bcm2835-cpufreq.c -+++ b/drivers/cpufreq/bcm2835-cpufreq.c -@@ -1,25 +1,17 @@ --/***************************************************************************** --* Copyright 2011 Broadcom Corporation. All rights reserved. --* --* Unless you and Broadcom execute a separate written software license --* agreement governing use of this software, this software is licensed to you --* under the terms of the GNU General Public License version 2, available at --* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). --* --* Notwithstanding the above, under no circumstances may you combine this --* software in any way with any other Broadcom software provided under a --* license other than the GPL, without Broadcom's express prior written --* consent. --*****************************************************************************/ -- --/***************************************************************************** --* FILENAME: bcm2835-cpufreq.h --* DESCRIPTION: This driver dynamically manages the CPU Frequency of the ARM --* processor. Messages are sent to Videocore either setting or requesting the --* frequency of the ARM in order to match an appropiate frequency to the current --* usage of the processor. The policy which selects the frequency to use is --* defined in the kernel .config file, but can be changed during runtime. --*****************************************************************************/ -+/* -+ * Copyright 2011 Broadcom Corporation. -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; version 2 -+ * of the License. -+ * -+ * This driver dynamically manages the CPU Frequency of the ARM -+ * processor. Messages are sent to Videocore either setting or requesting the -+ * frequency of the ARM in order to match an appropiate frequency to the current -+ * usage of the processor. The policy which selects the frequency to use is -+ * defined in the kernel .config file, but can be changed during runtime. -+ */ - - /* ---------- INCLUDES ---------- */ - #include - -From 4ce3dfd1ea9a66cc9f1582a43db0fef011c6309a Mon Sep 17 00:00:00 2001 -From: Eric Anholt -Date: Wed, 21 Jun 2017 09:03:51 -0700 -Subject: [PATCH 158/199] bcm2708: Drop CMA alignment from FKMS mode as well. - -I dropped it from KMS mode in d88274d88ed81de1ade8e18e4c0ed91792ec82ea -and should have done both of them at that time. - -Signed-off-by: Eric Anholt ---- - arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts b/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts -index 95a595a35cb4fbb707bf4b18161f6a46860aa4ae..36fbf6c8c2e612a6dc5aa02d77cc8173098c16ca 100644 ---- a/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts -+++ b/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts -@@ -11,35 +11,35 @@ - fragment@0 { - target-path = "/chosen"; - __overlay__ { -- bootargs = "cma=256M@256M"; -+ bootargs = "cma=256M"; - }; - }; - - fragment@1 { - target-path = "/chosen"; - __dormant__ { -- bootargs = "cma=192M@256M"; -+ bootargs = "cma=192M"; - }; - }; - - fragment@2 { - target-path = "/chosen"; - __dormant__ { -- bootargs = "cma=128M@128M"; -+ bootargs = "cma=128M"; - }; - }; - - fragment@3 { - target-path = "/chosen"; - __dormant__ { -- bootargs = "cma=96M@128M"; -+ bootargs = "cma=96M"; - }; - }; - - fragment@4 { - target-path = "/chosen"; - __dormant__ { -- bootargs = "cma=64M@64M"; -+ bootargs = "cma=64M"; - }; - }; - - -From c7ab84da6b4e2bc7257567b056247fed250a1c4b Mon Sep 17 00:00:00 2001 -From: Steve Conner -Date: Thu, 29 Jun 2017 15:56:19 +0100 -Subject: [PATCH 159/199] New i2c-rtc-gpio device overlay (#2092) - -Created new i2c-rtc-gpio device overlay by combining i2c-rtc and i2c-gpio. Tested with PCF2127 on CM3. ---- - arch/arm/boot/dts/overlays/Makefile | 1 + - arch/arm/boot/dts/overlays/README | 41 +++++ - .../arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts | 183 +++++++++++++++++++++ - 3 files changed, 225 insertions(+) - create mode 100644 arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts - -diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile -index eca81982c0f19988abd05165fc62a80d26f539cb..8a3131f5a4bc90d4a597b416416953e8e49d41ec 100644 ---- a/arch/arm/boot/dts/overlays/Makefile -+++ b/arch/arm/boot/dts/overlays/Makefile -@@ -42,6 +42,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ - i2c-mux.dtbo \ - i2c-pwm-pca9685a.dtbo \ - i2c-rtc.dtbo \ -+ i2c-rtc-gpio.dtbo \ - i2c-sensor.dtbo \ - i2c0-bcm2708.dtbo \ - i2c1-bcm2708.dtbo \ -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index 19df6883be4277240283d5f63f27e34a22a2eec5..a69e3a0d8dce1633598dd3cd8e00cad9509eee03 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -662,6 +662,47 @@ Params: abx80x Select one of the ABx80x family: - source - - -+Name: i2c-rtc-gpio -+Info: Adds support for a number of I2C Real Time Clock devices -+ using the software i2c controller -+Load: dtoverlay=i2c-rtc-gpio,= -+Params: abx80x Select one of the ABx80x family: -+ AB0801, AB0803, AB0804, AB0805, -+ AB1801, AB1803, AB1804, AB1805 -+ -+ ds1307 Select the DS1307 device -+ -+ ds1339 Select the DS1339 device -+ -+ ds3231 Select the DS3231 device -+ -+ mcp7940x Select the MCP7940x device -+ -+ mcp7941x Select the MCP7941x device -+ -+ pcf2127 Select the PCF2127 device -+ -+ pcf8523 Select the PCF8523 device -+ -+ pcf8563 Select the PCF8563 device -+ -+ trickle-diode-type Diode type for trickle charge - "standard" or -+ "schottky" (ABx80x only) -+ -+ trickle-resistor-ohms Resistor value for trickle charge (DS1339, -+ ABx80x) -+ -+ wakeup-source Specify that the RTC can be used as a wakeup -+ source -+ -+ i2c_gpio_sda GPIO used for I2C data (default "23") -+ -+ i2c_gpio_scl GPIO used for I2C clock (default "24") -+ -+ i2c_gpio_delay_us Clock delay in microseconds -+ (default "2" = ~100kHz) -+ -+ - Name: i2c-sensor - Info: Adds support for a number of I2C barometric pressure and temperature - sensors on i2c_arm -diff --git a/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts b/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts -new file mode 100644 -index 0000000000000000000000000000000000000000..8415e6081428fba9a47682964174fc023cfd2b0c ---- /dev/null -+++ b/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts -@@ -0,0 +1,183 @@ -+// Definitions for several I2C based Real Time Clocks -+// Available through i2c-gpio -+/dts-v1/; -+/plugin/; -+ -+/ { -+ compatible = "brcm,bcm2708"; -+ -+ fragment@0 { -+ target-path = "/"; -+ __overlay__ { -+ i2c_gpio: i2c-gpio-rtc@0 { -+ compatible = "i2c-gpio"; -+ gpios = <&gpio 23 0 /* sda */ -+ &gpio 24 0 /* scl */ -+ >; -+ i2c-gpio,delay-us = <2>; /* ~100 kHz */ -+ #address-cells = <1>; -+ #size-cells = <0>; -+ }; -+ }; -+ }; -+ -+ fragment@1 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ abx80x: abx80x@69 { -+ compatible = "abracon,abx80x"; -+ reg = <0x69>; -+ abracon,tc-diode = "standard"; -+ abracon,tc-resistor = <0>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@2 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ ds1307: ds1307@68 { -+ compatible = "maxim,ds1307"; -+ reg = <0x68>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@3 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ ds1339: ds1339@68 { -+ compatible = "dallas,ds1339"; -+ trickle-resistor-ohms = <0>; -+ reg = <0x68>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@4 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ ds3231: ds3231@68 { -+ compatible = "maxim,ds3231"; -+ reg = <0x68>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@5 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ mcp7940x: mcp7940x@6f { -+ compatible = "microchip,mcp7940x"; -+ reg = <0x6f>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@6 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ mcp7941x: mcp7941x@6f { -+ compatible = "microchip,mcp7941x"; -+ reg = <0x6f>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@7 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ pcf2127: pcf2127@51 { -+ compatible = "nxp,pcf2127"; -+ reg = <0x51>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@8 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ pcf8523: pcf8523@68 { -+ compatible = "nxp,pcf8523"; -+ reg = <0x68>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ fragment@9 { -+ target = <&i2c_gpio>; -+ __dormant__ { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ status = "okay"; -+ -+ pcf8563: pcf8563@51 { -+ compatible = "nxp,pcf8563"; -+ reg = <0x51>; -+ status = "okay"; -+ }; -+ }; -+ }; -+ -+ __overrides__ { -+ abx80x = <0>,"+1"; -+ ds1307 = <0>,"+2"; -+ ds1339 = <0>,"+3"; -+ ds3231 = <0>,"+4"; -+ mcp7940x = <0>,"+5"; -+ mcp7941x = <0>,"+6"; -+ pcf2127 = <0>,"+7"; -+ pcf8523 = <0>,"+8"; -+ pcf8563 = <0>,"+9"; -+ trickle-diode-type = <&abx80x>,"abracon,tc-diode"; -+ trickle-resistor-ohms = <&ds1339>,"trickle-resistor-ohms:0", -+ <&abx80x>,"abracon,tc-resistor"; -+ wakeup-source = <&ds1339>,"wakeup-source?", -+ <&ds3231>,"wakeup-source?", -+ <&mcp7940x>,"wakeup-source?", -+ <&mcp7941x>,"wakeup-source?"; -+ i2c_gpio_sda = <&i2c_gpio>,"gpios:4"; -+ i2c_gpio_scl = <&i2c_gpio>,"gpios:16"; -+ i2c_gpio_delay_us = <&i2c_gpio>,"i2c-gpio,delay-us:0"; -+ }; -+}; - -From 547e83222054f994be34a521a2792944576a9930 Mon Sep 17 00:00:00 2001 -From: Allo -Date: Mon, 3 Jul 2017 15:45:20 +0530 -Subject: [PATCH 160/199] PianoPlus: Dual Mono & Dual Stereo features added - (#2069) - ---- - sound/soc/bcm/allo-piano-dac-plus.c | 160 +++++++++++++++++++++++++++++++----- - 1 file changed, 141 insertions(+), 19 deletions(-) - -diff --git a/sound/soc/bcm/allo-piano-dac-plus.c b/sound/soc/bcm/allo-piano-dac-plus.c -index 56e43f98846b41e487b3089813f7edc3c08517eb..d4e99e3c6a383d92fb0cf9e8c1cd1e7657358d49 100644 ---- a/sound/soc/bcm/allo-piano-dac-plus.c -+++ b/sound/soc/bcm/allo-piano-dac-plus.c -@@ -36,6 +36,7 @@ struct dsp_code { - - struct glb_pool { - struct mutex lock; -+ unsigned int dual_mode; - unsigned int set_lowpass; - unsigned int set_mode; - unsigned int set_rate; -@@ -47,8 +48,8 @@ bool glb_mclk; - - static struct gpio_desc *mute_gpio[2]; - -- - static const char * const allo_piano_mode_texts[] = { -+ "None", - "2.0", - "2.1", - "2.2", -@@ -57,6 +58,15 @@ static const char * const allo_piano_mode_texts[] = { - static const SOC_ENUM_SINGLE_DECL(allo_piano_mode_enum, - 0, 0, allo_piano_mode_texts); - -+static const char * const allo_piano_dual_mode_texts[] = { -+ "None", -+ "Dual-Mono", -+ "Dual-Stereo", -+}; -+ -+static const SOC_ENUM_SINGLE_DECL(allo_piano_dual_mode_enum, -+ 0, 0, allo_piano_dual_mode_texts); -+ - static const char * const allo_piano_dsp_low_pass_texts[] = { - "60", - "70", -@@ -82,10 +92,10 @@ static int __snd_allo_piano_dsp_program(struct snd_soc_pcm_runtime *rtd, - unsigned int mode, unsigned int rate, unsigned int lowpass) - { - const struct firmware *fw; -- char firmware_name[60]; -- int ret = 0, dac = 0; - struct snd_soc_card *card = rtd->card; - struct glb_pool *glb_ptr = card->drvdata; -+ char firmware_name[60]; -+ int ret = 0, dac = 0; - - if (rate <= 46000) - rate = 44100; -@@ -100,26 +110,35 @@ static int __snd_allo_piano_dsp_program(struct snd_soc_pcm_runtime *rtd, - else - rate = 192000; - -- if ((lowpass > 14) || (lowpass < 0)) -- lowpass = 3; -- if ((mode > 2) || (mode < 0)) -- mode = 0; -+ if (lowpass > 14) -+ glb_ptr->set_lowpass = lowpass = 3; -+ -+ if (mode > 3) -+ glb_ptr->set_mode = mode = 0; -+ -+ if (mode > 0) -+ glb_ptr->dual_mode = 0; - - /* same configuration loaded */ - if ((rate == glb_ptr->set_rate) && (lowpass == glb_ptr->set_lowpass) - && (mode == glb_ptr->set_mode)) - return 0; - -- if (mode == 0) { /* 2.0 */ -- snd_soc_write(rtd->codec_dais[1]->codec, -- PCM512x_MUTE, 0x11); -+ switch (mode) { -+ case 0: /* None */ -+ return 1; -+ -+ case 1: /* 2.0 */ -+ snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x00); -+ snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x11); - glb_ptr->set_rate = rate; - glb_ptr->set_mode = mode; - glb_ptr->set_lowpass = lowpass; - return 1; -- } else { -- snd_soc_write(rtd->codec_dais[1]->codec, -- PCM512x_MUTE, 0x00); -+ -+ default: -+ snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x00); -+ snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x00); - } - - for (dac = 0; dac < rtd->num_codecs; dac++) { -@@ -128,13 +147,13 @@ static int __snd_allo_piano_dsp_program(struct snd_soc_pcm_runtime *rtd, - int i = 1; - - if (dac == 0) { /* high */ -- sprintf(firmware_name, -+ snprintf(firmware_name, sizeof(firmware_name), - "allo/piano/2.2/allo-piano-dsp-%d-%d-%d.bin", - rate, ((lowpass * 10) + 60), dac); - } else { /* low */ -- sprintf(firmware_name, -+ snprintf(firmware_name, sizeof(firmware_name), - "allo/piano/2.%d/allo-piano-dsp-%d-%d-%d.bin", -- mode, rate, ((lowpass * 10) + 60), dac); -+ (mode - 1), rate, ((lowpass * 10) + 60), dac); - } - - dev_info(codec->dev, "Dsp Firmware File Name: %s\n", -@@ -199,6 +218,80 @@ static int snd_allo_piano_dsp_program(struct snd_soc_pcm_runtime *rtd, - return ret; - } - -+static int snd_allo_piano_dual_mode_get(struct snd_kcontrol *kcontrol, -+ struct snd_ctl_elem_value *ucontrol) -+{ -+ struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); -+ struct glb_pool *glb_ptr = card->drvdata; -+ -+ ucontrol->value.integer.value[0] = glb_ptr->dual_mode; -+ -+ return 0; -+} -+ -+static int snd_allo_piano_dual_mode_put(struct snd_kcontrol *kcontrol, -+ struct snd_ctl_elem_value *ucontrol) -+{ -+ struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); -+ struct glb_pool *glb_ptr = card->drvdata; -+ struct snd_soc_pcm_runtime *rtd; -+ struct snd_card *snd_card_ptr = card->snd_card; -+ struct snd_kcontrol *kctl; -+ struct soc_mixer_control *mc; -+ unsigned int left_val = 0; -+ -+ rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); -+ -+ if (ucontrol->value.integer.value[0] > 0) { -+ glb_ptr->dual_mode = ucontrol->value.integer.value[0]; -+ glb_ptr->set_mode = 0; -+ } else if (ucontrol->value.integer.value[0] <= 0) { -+ if (glb_ptr->set_mode <= 0) { -+ glb_ptr->dual_mode = 1; -+ glb_ptr->set_mode = 0; -+ } -+ } else { -+ glb_ptr->dual_mode = 0; -+ return 0; -+ } -+ -+ if (glb_ptr->dual_mode == 1) { -+ snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x01); -+ snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x10); -+ snd_soc_write(rtd->codec_dais[0]->codec, -+ PCM512x_DIGITAL_VOLUME_3, 0xff); -+ -+ list_for_each_entry(kctl, &snd_card_ptr->controls, list) { -+ if (!strncmp(kctl->id.name, "Digital Playback Volume", -+ sizeof(kctl->id.name))) { -+ mc = (struct soc_mixer_control *) -+ kctl->private_value; -+ mc->rreg = mc->reg; -+ break; -+ } -+ } -+ } else { -+ left_val = snd_soc_read(rtd->codec_dais[0]->codec, -+ PCM512x_DIGITAL_VOLUME_2); -+ list_for_each_entry(kctl, &snd_card_ptr->controls, list) { -+ if (!strncmp(kctl->id.name, "Digital Playback Volume", -+ sizeof(kctl->id.name))) { -+ mc = (struct soc_mixer_control *) -+ kctl->private_value; -+ mc->rreg = PCM512x_DIGITAL_VOLUME_3; -+ break; -+ } -+ } -+ -+ snd_soc_write(rtd->codec_dais[0]->codec, -+ PCM512x_DIGITAL_VOLUME_3, left_val); -+ snd_soc_write(rtd->codec_dais[0]->codec, PCM512x_MUTE, 0x00); -+ snd_soc_write(rtd->codec_dais[1]->codec, PCM512x_MUTE, 0x00); -+ } -+ -+ return 0; -+} -+ - static int snd_allo_piano_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) - { -@@ -215,8 +308,30 @@ static int snd_allo_piano_mode_put(struct snd_kcontrol *kcontrol, - struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); - struct snd_soc_pcm_runtime *rtd; - struct glb_pool *glb_ptr = card->drvdata; -+ struct snd_card *snd_card_ptr = card->snd_card; -+ struct snd_kcontrol *kctl; -+ struct soc_mixer_control *mc; -+ unsigned int left_val = 0; - - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); -+ -+ if ((glb_ptr->dual_mode == 1) && -+ (ucontrol->value.integer.value[0] > 0)) { -+ left_val = snd_soc_read(rtd->codec_dais[0]->codec, -+ PCM512x_DIGITAL_VOLUME_2); -+ list_for_each_entry(kctl, &snd_card_ptr->controls, list) { -+ if (!strncmp(kctl->id.name, "Digital Playback Volume", -+ sizeof(kctl->id.name))) { -+ mc = (struct soc_mixer_control *) -+ kctl->private_value; -+ mc->rreg = PCM512x_DIGITAL_VOLUME_3; -+ break; -+ } -+ } -+ snd_soc_write(rtd->codec_dais[0]->codec, -+ PCM512x_DIGITAL_VOLUME_3, left_val); -+ } -+ - return(snd_allo_piano_dsp_program(rtd, - ucontrol->value.integer.value[0], - glb_ptr->set_rate, glb_ptr->set_lowpass)); -@@ -344,6 +459,11 @@ static const struct snd_kcontrol_new allo_piano_controls[] = { - snd_allo_piano_mode_get, - snd_allo_piano_mode_put), - -+ SOC_ENUM_EXT("Dual Mode Route", -+ allo_piano_dual_mode_enum, -+ snd_allo_piano_dual_mode_get, -+ snd_allo_piano_dual_mode_put), -+ - SOC_ENUM_EXT("Lowpass Route", allo_piano_enum, - snd_allo_piano_lowpass_get, - snd_allo_piano_lowpass_put), -@@ -472,7 +592,7 @@ static int snd_allo_piano_dac_hw_params( - PCM512x_RATE_DET_4); - if (val < 0) { - dev_err(rtd->codec_dais[dac]->codec->dev, -- "Failed to read register PCM512x_RATE_DET_4\n"); -+ "Failed to read register PCM512x_RATE_DET_4\n"); - return val; - } - -@@ -482,7 +602,7 @@ static int snd_allo_piano_dac_hw_params( - PCM512x_SREF_BCK); - - dev_info(rtd->codec_dais[dac]->codec->dev, -- "Setting BCLK as input clock & Enable PLL\n"); -+ "Setting BCLK as input clock & Enable PLL\n"); - } else { - snd_soc_write(rtd->codec_dais[dac]->codec, - PCM512x_PLL_EN, -@@ -493,7 +613,7 @@ static int snd_allo_piano_dac_hw_params( - PCM512x_SREF_SCK); - - dev_info(rtd->codec_dais[dac]->codec->dev, -- "Setting SCLK as input clock & disabled PLL\n"); -+ "Setting SCLK as input clock & disabled PLL\n"); - } - } - -@@ -504,6 +624,7 @@ static int snd_allo_piano_dac_hw_params( - dev_warn(card->dev, "Failed to set volume limit: %d\n", - ret); - } -+ - ret = snd_allo_piano_dsp_program(rtd, glb_ptr->set_mode, rate, - glb_ptr->set_lowpass); - if (ret < 0) -@@ -521,6 +642,7 @@ static int snd_allo_piano_dac_prepare( - struct snd_soc_card *card = rtd->card; - - snd_allo_piano_gpio_unmute(card); -+ - return 0; - } - - -From 9c8b2225d69f22e5362891045b4490c2c8fa6b47 Mon Sep 17 00:00:00 2001 -From: Matthijs Kooijman -Date: Sun, 9 Jul 2017 15:15:22 +0200 -Subject: [PATCH 161/199] overlays: Add gpio-shutdown overlay (#2103) - -This overlay facilitates the addition of a powerbutton by converting -GPIO edges into KEY_POWER keypresses, which can be handled by -systemd-logind to shut down the system. - -Signed-off-by: Matthijs Kooijman ---- - arch/arm/boot/dts/overlays/Makefile | 1 + - arch/arm/boot/dts/overlays/README | 32 +++++++++ - .../boot/dts/overlays/gpio-shutdown-overlay.dts | 80 ++++++++++++++++++++++ - 3 files changed, 113 insertions(+) - create mode 100644 arch/arm/boot/dts/overlays/gpio-shutdown-overlay.dts - -diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile -index 8a3131f5a4bc90d4a597b416416953e8e49d41ec..c50b1dfa9d7334df47ce087f9d2a7a816afa05ba 100644 ---- a/arch/arm/boot/dts/overlays/Makefile -+++ b/arch/arm/boot/dts/overlays/Makefile -@@ -30,6 +30,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ - googlevoicehat-soundcard.dtbo \ - gpio-ir.dtbo \ - gpio-poweroff.dtbo \ -+ gpio-shutdown.dtbo \ - hifiberry-amp.dtbo \ - hifiberry-dac.dtbo \ - hifiberry-dacplus.dtbo \ -diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README -index a69e3a0d8dce1633598dd3cd8e00cad9509eee03..e6d777a601c91d192bc5713f9a73e1a2d4d708ef 100644 ---- a/arch/arm/boot/dts/overlays/README -+++ b/arch/arm/boot/dts/overlays/README -@@ -508,6 +508,38 @@ Params: gpiopin GPIO for signalling (default 26) - will also cause the pin to go low. - - -+Name: gpio-shutdown -+Info: Initiates a shutdown when GPIO pin changes. The given GPIO pin -+ is configured as an input key that generates KEY_POWER events. -+ This event is handled by systemd-logind by initiating a -+ shutdown. Systemd versions older than 225 need an udev rule -+ enable listening to the input device: -+ -+ ACTION!="REMOVE", SUBSYSTEM=="input", KERNEL=="event*", \ -+ SUBSYSTEMS=="platform", DRIVERS=="gpio-keys", \ -+ ATTRS{keys}=="116", TAG+="power-switch" -+ -+ This overlay only handles shutdown. After shutdown, the system -+ can be powered up again by driving GPIO3 low. The default -+ configuration uses GPIO3 with a pullup, so if you connect a -+ button between GPIO3 and GND (pin 5 and 6 on the 40-pin header), -+ you get a shutdown and power-up button. -+Load: dtoverlay=gpio-shutdown,= -+Params: gpio_pin GPIO pin to trigger on (default 3) -+ -+ active_low When this is 1 (active low), a falling -+ edge generates a key down event and a -+ rising edge generates a key up event. -+ When this is 0 (active high), this is -+ reversed. The default is 1 (active low). -+ -+ gpio_pull Desired pull-up/down state (off, down, up) -+ Default is "up". -+ -+ Note that the default pin (GPIO3) has an -+ external pullup. -+ -+ - Name: hifiberry-amp - Info: Configures the HifiBerry Amp and Amp+ audio cards - Load: dtoverlay=hifiberry-amp -diff --git a/arch/arm/boot/dts/overlays/gpio-shutdown-overlay.dts b/arch/arm/boot/dts/overlays/gpio-shutdown-overlay.dts -new file mode 100644 -index 0000000000000000000000000000000000000000..863fb395c8539734b658682b900e1fbd96c9443e ---- /dev/null -+++ b/arch/arm/boot/dts/overlays/gpio-shutdown-overlay.dts -@@ -0,0 +1,80 @@ -+// Definitions for gpio-poweroff module -+/dts-v1/; -+/plugin/; -+ -+// This overlay sets up an input device that generates KEY_POWER events -+// when a given GPIO pin changes. It defaults to using GPIO3, which can -+// also be used to wake up (start) the Rpi again after shutdown. Since -+// wakeup is active-low, this defaults to active-low with a pullup -+// enabled, but all of this can be changed using overlay parameters (but -+// note that GPIO3 has an external pullup on at least some boards). -+ -+/ { -+ compatible = "brcm,bcm2708"; -+ -+ fragment@0 { -+ // Configure the gpio pin controller -+ target = <&gpio>; -+ __overlay__ { -+ // Define a pinctrl state, that sets up the gpio -+ // as an input with a pullup enabled. This does -+ // not take effect by itself, only when referenced -+ // by a "pinctrl client", as is done below. See: -+ // https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt -+ // https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/brcm,bcm2835-gpio.txt -+ pin_state: shutdown_button_pins { -+ brcm,pins = <3>; // gpio number -+ brcm,function = <0>; // 0 = input, 1 = output -+ brcm,pull = <2>; // 0 = none, 1 = pull down, 2 = pull up -+ }; -+ }; -+ }; -+ fragment@1 { -+ // Add a new device to the /soc devicetree node -+ target-path = "/soc"; -+ __overlay__ { -+ shutdown_button { -+ // Let the gpio-keys driver handle this device. See: -+ // https://www.kernel.org/doc/Documentation/devicetree/bindings/input/gpio-keys.txt -+ compatible = "gpio-keys"; -+ -+ // Declare a single pinctrl state (referencing the one declared above) and name it -+ // default, so it is activated automatically. -+ pinctrl-names = "default"; -+ pinctrl-0 = <&pin_state>; -+ -+ // Enable this device -+ status = "okay"; -+ -+ // Define a single key, called "shutdown" that monitors the gpio and sends KEY_POWER -+ // (keycode 116, see -+ // https://github.com/torvalds/linux/blob/v4.12/include/uapi/linux/input-event-codes.h#L190) -+ button: shutdown { -+ label = "shutdown"; -+ linux,code = <116>; // KEY_POWER -+ gpios = <&gpio 3 1>; -+ }; -+ }; -+ }; -+ }; -+ -+ // This defines parameters that can be specified when loading -+ // the overlay. Each foo = line specifies one parameter, named -+ // foo. The rest of the specification gives properties where the -+ // parameter value is inserted into (changing the values above -+ // or adding new ones). -+ __overrides__ { -+ // Allow overriding the GPIO number. -+ gpio_pin = <&button>,"gpios:4", -+ <&pin_state>,"brcm,pins:0"; -+ -+ // Allow changing the internal pullup/down state. 0 = none, 1 = pulldown, 2 = pullup -+ // Note that GPIO3 and GPIO2 are the I2c pins and have an external pullup (at least -+ // on some boards). -+ gpio_pull = <&pin_state>,"brcm,pull:0"; -+ -+ // Allow setting the active_low flag. 0 = active high, 1 = active low -+ active_low = <&button>,"gpios:8"; -+ }; -+ -+}; - -From 21d1516665338a99d6decc6fe70c5ed47058818c Mon Sep 17 00:00:00 2001 -From: Matthias Reichl -Date: Mon, 10 Jul 2017 11:05:17 +0200 -Subject: [PATCH 162/199] config: enable generic S/PDIF codec drivers (#2104) - -These drivers can be used as dummy ADC/DAC drivers for -attaching general codecs that don't need to be configured. - -This option will build 2 additional drivers, spdif_receiver -and spdif_transmitter. - -Since these drivers have DT bindings they are handy for quick -testing of I2S peripherals with simple-audio-card. - -eg: - -fragment@0 { - target-path = "/"; - __overlay__ { - dummy_receiver: spdif-receiver { - #address-cells = <0>; - #size-cells = <0>; - #sound-dai-cells = <0>; - compatible = "linux,spdif-dir"; - status = "okay"; - }; - }; -}; - -Signed-off-by: Matthias Reichl ---- - arch/arm/configs/bcm2709_defconfig | 1 + - arch/arm/configs/bcmrpi_defconfig | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index d2838cde4019be5f6faf0a70038c6365df9e6dde..6f49e2b69f0cb27154dd26eba20eabdde2d60052 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -898,6 +898,7 @@ CONFIG_SND_PISOUND=m - CONFIG_SND_SOC_ADAU1701=m - CONFIG_SND_SOC_ADAU7002=m - CONFIG_SND_SOC_AK4554=m -+CONFIG_SND_SOC_SPDIF=m - CONFIG_SND_SOC_WM8804_I2C=m - CONFIG_SND_SIMPLE_CARD=m - CONFIG_HIDRAW=y -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index efdb0fbc1b07c7b679cb20d8c1270c77d5d3c684..472a330439a19ac5d4f70c22059f015816823694 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -891,6 +891,7 @@ CONFIG_SND_PISOUND=m - CONFIG_SND_SOC_ADAU1701=m - CONFIG_SND_SOC_ADAU7002=m - CONFIG_SND_SOC_AK4554=m -+CONFIG_SND_SOC_SPDIF=m - CONFIG_SND_SOC_WM8804_I2C=m - CONFIG_SND_SIMPLE_CARD=m - CONFIG_HIDRAW=y - -From 542f21c01f0f3e5427ec08548f452eced6ec500b Mon Sep 17 00:00:00 2001 -From: Bilal Amarni -Date: Wed, 24 May 2017 10:52:50 +0200 -Subject: [PATCH 163/199] [ARM64] enable drivers for GPIO expander and vcio - ---- - arch/arm64/configs/bcmrpi3_defconfig | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/arch/arm64/configs/bcmrpi3_defconfig b/arch/arm64/configs/bcmrpi3_defconfig -index 4d85c231c5ea0244e1b05fb4a5e3c8fd3e651ddf..9dcb58a519d041fadae99c81a7bda621b2a49f12 100644 ---- a/arch/arm64/configs/bcmrpi3_defconfig -+++ b/arch/arm64/configs/bcmrpi3_defconfig -@@ -575,6 +575,8 @@ CONFIG_SERIO_RAW=m - CONFIG_GAMEPORT=m - CONFIG_GAMEPORT_NS558=m - CONFIG_GAMEPORT_L4=m -+CONFIG_BRCM_CHAR_DRIVERS=y -+CONFIG_BCM_VCIO=y - # CONFIG_BCM2835_DEVGPIOMEM is not set - # CONFIG_BCM2835_SMI_DEV is not set - # CONFIG_LEGACY_PTYS is not set -@@ -609,6 +611,7 @@ CONFIG_PPS=m - CONFIG_PPS_CLIENT_LDISC=m - CONFIG_PPS_CLIENT_GPIO=m - CONFIG_GPIO_SYSFS=y -+CONFIG_GPIO_BCM_EXP=y - CONFIG_GPIO_BCM_VIRT=y - CONFIG_GPIO_ARIZONA=m - CONFIG_GPIO_STMPE=y - -From 73345bb3d3cd24d3e80531e6be7c05eb123f1655 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Fri, 14 Jul 2017 12:59:55 +0100 -Subject: [PATCH 164/199] bcm2835-mmc: Fix DMA usage - -The previous change ("bcm2835-mmc: Only claim one DMA channel") -used an incorrect variable, the effect of which was to prevent -DMA from being used at all. Fix that bug by using the right -variable. - -Signed-off-by: Phil Elwell ---- - drivers/mmc/host/bcm2835-mmc.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/drivers/mmc/host/bcm2835-mmc.c b/drivers/mmc/host/bcm2835-mmc.c -index 4fe8d1fe44578fbefcd48f8c327ba3d03f3d0a2a..981db05de1ff52a83550e41ab362eecf99cafa29 100644 ---- a/drivers/mmc/host/bcm2835-mmc.c -+++ b/drivers/mmc/host/bcm2835-mmc.c -@@ -1354,14 +1354,14 @@ static int bcm2835_mmc_add_host(struct bcm2835_host *host) - if (ret == 0) { - host->dma_cfg_rx = cfg; - -- host->use_dma = true; -+ host->have_dma = true; - } else { - pr_err("%s: unable to configure DMA channel. " -- "Faling back to PIO\n", -+ "Falling back to PIO\n", - mmc_hostname(mmc)); - dma_release_channel(host->dma_chan_rxtx); - host->dma_chan_rxtx = NULL; -- host->use_dma = false; -+ host->have_dma = false; - } - } - #endif - -From fb6e916972bc742b21a85990d7500046eab1eb17 Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Sun, 16 Jul 2017 21:39:16 +0100 -Subject: [PATCH 165/199] BCM270X_DT: Use the upstream thermal-zones DT node - -Signed-off-by: Phil Elwell ---- - arch/arm/boot/dts/bcm2708-rpi.dtsi | 30 ++++++------------------------ - 1 file changed, 6 insertions(+), 24 deletions(-) - -diff --git a/arch/arm/boot/dts/bcm2708-rpi.dtsi b/arch/arm/boot/dts/bcm2708-rpi.dtsi -index 29dde110e769082a24640d3c7284afb8e99b226c..8cc83a350d02bb485f7a4fcb129df9e00fb3f958 100644 ---- a/arch/arm/boot/dts/bcm2708-rpi.dtsi -+++ b/arch/arm/boot/dts/bcm2708-rpi.dtsi -@@ -90,30 +90,6 @@ - sound: sound { - status = "disabled"; - }; -- -- thermal-zones { -- cpu_thermal: cpu-thermal { -- polling-delay-passive = <0>; -- polling-delay = <1000>; -- -- thermal-sensors = <&thermal>; -- -- /* No trips -- trips { -- cpu-crit { -- temperature = <80000>; -- hysteresis = <0>; -- type = "critical"; -- }; -- }; -- */ -- -- coefficients = <(-538) 407000>; -- -- cooling-maps { -- }; -- }; -- }; - }; - - __overrides__ { -@@ -172,3 +148,9 @@ sdhost_pins: &sdhost_gpio48 { - &fb { - status = "okay"; - }; -+ -+&cpu_thermal { -+ coefficients = <(-538) 407000>; -+ -+ /delete-node/ trips; -+}; - -From 65c5ea6e4cb5b2950f0c27ed8b772e9137c35975 Mon Sep 17 00:00:00 2001 -From: Conn -Date: Mon, 17 Jul 2017 03:25:43 +0100 -Subject: [PATCH 166/199] config: enhance DualShock3 controller support - -Enable rumble support in Sony HID & HID battery strength. ---- - arch/arm/configs/bcm2709_defconfig | 2 ++ - arch/arm/configs/bcmrpi_defconfig | 2 ++ - 2 files changed, 4 insertions(+) - -diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig -index 6f49e2b69f0cb27154dd26eba20eabdde2d60052..62909413e1d625a1d33559d965ee8707ca57ba91 100644 ---- a/arch/arm/configs/bcm2709_defconfig -+++ b/arch/arm/configs/bcm2709_defconfig -@@ -901,6 +901,7 @@ CONFIG_SND_SOC_AK4554=m - CONFIG_SND_SOC_SPDIF=m - CONFIG_SND_SOC_WM8804_I2C=m - CONFIG_SND_SIMPLE_CARD=m -+CONFIG_HID_BATTERY_STRENGTH=y - CONFIG_HIDRAW=y - CONFIG_UHID=m - CONFIG_HID_A4TECH=m -@@ -943,6 +944,7 @@ CONFIG_HID_PICOLCD=m - CONFIG_HID_ROCCAT=m - CONFIG_HID_SAMSUNG=m - CONFIG_HID_SONY=m -+CONFIG_SONY_FF=y - CONFIG_HID_SPEEDLINK=m - CONFIG_HID_SUNPLUS=m - CONFIG_HID_GREENASIA=m -diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig -index 472a330439a19ac5d4f70c22059f015816823694..e0dd8723047ff488e81a03ef42fdbc68c43dc721 100644 ---- a/arch/arm/configs/bcmrpi_defconfig -+++ b/arch/arm/configs/bcmrpi_defconfig -@@ -894,6 +894,7 @@ CONFIG_SND_SOC_AK4554=m - CONFIG_SND_SOC_SPDIF=m - CONFIG_SND_SOC_WM8804_I2C=m - CONFIG_SND_SIMPLE_CARD=m -+CONFIG_HID_BATTERY_STRENGTH=y - CONFIG_HIDRAW=y - CONFIG_UHID=m - CONFIG_HID_A4TECH=m -@@ -936,6 +937,7 @@ CONFIG_HID_PICOLCD=m - CONFIG_HID_ROCCAT=m - CONFIG_HID_SAMSUNG=m - CONFIG_HID_SONY=m -+CONFIG_SONY_FF=y - CONFIG_HID_SPEEDLINK=m - CONFIG_HID_SUNPLUS=m - CONFIG_HID_GREENASIA=m - -From feb8aaa3a587b0d0586da870c2e3a36bd6b94ad7 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Wed, 19 Jul 2017 15:20:50 +0100 -Subject: [PATCH 167/199] overlays: i2c1-bcm2708: Don't overwrite i2c1 pins - node - -It is bad practise to overwrite an entire node in an overlay. Instead, -target the node and overwrite any properties that need changing. - -See: https://github.com/raspberrypi/linux/pull/2118 - -Suggested-by: soodvarun78 -Signed-off-by: Phil Elwell ---- - arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts | 17 +++++++---------- - 1 file changed, 7 insertions(+), 10 deletions(-) - -diff --git a/arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts b/arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts -index e303b9c61c82a28eab7b48f6b085661574d5a849..7c69047bcd88a5c900dddd08e60ad0750b96d785 100644 ---- a/arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts -+++ b/arch/arm/boot/dts/overlays/i2c1-bcm2708-overlay.dts -@@ -20,18 +20,15 @@ - }; - - fragment@1 { -- target = <&gpio>; -- __overlay__ { -- i2c1_pins: i2c1 { -- brcm,pins = <2 3>; -- brcm,function = <4>; /* alt0 */ -- }; -+ target = <&i2c1_pins>; -+ pins: __overlay__ { -+ brcm,pins = <2 3>; -+ brcm,function = <4>; /* alt 0 */ - }; - }; -- - __overrides__ { -- sda1_pin = <&i2c1_pins>,"brcm,pins:0"; -- scl1_pin = <&i2c1_pins>,"brcm,pins:4"; -- pin_func = <&i2c1_pins>,"brcm,function:0"; -+ sda1_pin = <&pins>,"brcm,pins:0"; -+ scl1_pin = <&pins>,"brcm,pins:4"; -+ pin_func = <&pins>,"brcm,function:0"; - }; - }; - -From 9bc65e4fd1f183b88b75b8f39b75dc1a67c9fcf6 Mon Sep 17 00:00:00 2001 -From: Phil Elwell -Date: Tue, 18 Jul 2017 15:30:48 +0100 -Subject: [PATCH 168/199] bcm2835-mmc: Prevent DMA race condition - -The end of a read operation is triggered by the completion of the DMA -transfer, but writes are complete when the data IRQ is raised. The -bcm2835-mmc driver contains a race between the handling of the DMA -completion interrupt and the submission of the next request. Fix the -race by deferring the completion of the request until the DMA -transfer finishes. - -Signed-off-by: Phil Elwell ---- - drivers/mmc/host/bcm2835-mmc.c | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -diff --git a/drivers/mmc/host/bcm2835-mmc.c b/drivers/mmc/host/bcm2835-mmc.c -index 981db05de1ff52a83550e41ab362eecf99cafa29..c4a5e992c6fb4a40b933239350ed4bfc8fb40155 100644 ---- a/drivers/mmc/host/bcm2835-mmc.c -+++ b/drivers/mmc/host/bcm2835-mmc.c -@@ -115,6 +115,7 @@ struct bcm2835_host { - - bool have_dma; - bool use_dma; -+ bool wait_for_dma; - /*end of DMA part*/ - - int max_delay; /* maximum length of time spent waiting */ -@@ -341,6 +342,8 @@ static void bcm2835_mmc_dma_complete(void *param) - - spin_lock_irqsave(&host->lock, flags); - -+ host->use_dma = false; -+ - if (host->data && !(host->data->flags & MMC_DATA_WRITE)) { - /* otherwise handled in SDHCI IRQ */ - dma_chan = host->dma_chan_rxtx; -@@ -351,6 +354,9 @@ static void bcm2835_mmc_dma_complete(void *param) - dir_data); - - bcm2835_mmc_finish_data(host); -+ } else if (host->wait_for_dma) { -+ host->wait_for_dma = false; -+ tasklet_schedule(&host->finish_tasklet); - } - - spin_unlock_irqrestore(&host->lock, flags); -@@ -690,6 +696,7 @@ void bcm2835_mmc_send_command(struct bcm2835_host *host, struct mmc_command *cmd - mod_timer(&host->timer, timeout); - - host->cmd = cmd; -+ host->use_dma = false; - - bcm2835_mmc_prepare_data(host, cmd); - -@@ -759,8 +766,11 @@ static void bcm2835_mmc_finish_data(struct bcm2835_host *host) - } - - bcm2835_mmc_send_command(host, data->stop); -- } else -+ } else if (host->use_dma) { -+ host->wait_for_dma = true; -+ } else { - tasklet_schedule(&host->finish_tasklet); -+ } - } - - static void bcm2835_mmc_finish_command(struct bcm2835_host *host) - -From 4e41bebdfecead7b710734c79718629edd6a9ba7 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Sven=20K=C3=B6hler?= -Date: Mon, 7 Aug 2017 18:49:20 +0200 -Subject: [PATCH 169/199] Fix dependencies broken since driver was renamed - ---- - drivers/mmc/host/Kconfig | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig -index d47cce77c0551d78fa51f50e2c8086f26c7b9e56..dc41121c101e2ac6fe000fe2ab556561a340b78f 100644 ---- a/drivers/mmc/host/Kconfig -+++ b/drivers/mmc/host/Kconfig -@@ -25,7 +25,7 @@ config MMC_BCM2835_DMA - - config MMC_BCM2835_PIO_DMA_BARRIER - int "Block count limit for PIO transfers" -- depends on MMC_BCM2835 && MMC_BCM2835_DMA -+ depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA - range 0 256 - default 2 - help - -From 0ffd02d1a31a96cf40000d077a80d32cd0a35ead Mon Sep 17 00:00:00 2001 -From: Eric Anholt -Date: Thu, 18 Dec 2014 16:07:15 -0800 -Subject: [PATCH 170/199] mm: Remove the PFN busy warning - -See commit dae803e165a11bc88ca8dbc07a11077caf97bbcb -- the warning is -expected sometimes when using CMA. However, that commit still spams -my kernel log with these warnings. - -Signed-off-by: Eric Anholt ---- - mm/page_alloc.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/mm/page_alloc.c b/mm/page_alloc.c -index 1423da8dd16f5bdc83e20ddf6665b2022a9a6492..6ce930c02160d55dc4eee1e7197a5efa6ba7d44a 100644 ---- a/mm/page_alloc.c -+++ b/mm/page_alloc.c -@@ -7692,8 +7692,6 @@ int alloc_contig_range(unsigned long start, unsigned long end, - - /* Make sure the range is really isolated. */ - if (test_pages_isolated(outer_start, end, false)) { -- pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n", -- __func__, outer_start, end); - ret = -EBUSY; - goto done; - } - -From efc0b3db0e9f0358308a9cfd121282d2d4b3057d Mon Sep 17 00:00:00 2001 +From 574b675abdbbaeb89923f3538c5193bb347a7e33 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Fri, 25 Aug 2017 19:18:13 +0100 -Subject: [PATCH 171/199] cache: export clean and invalidate +Subject: [PATCH 129/129] cache: export clean and invalidate --- arch/arm/mm/cache-v6.S | 4 ++-- @@ -136731,5263 +134755,3 @@ index de78109d002db1a5e7c94a6c1bc8bb94161d07b8..4c850aa3af2b2439fced4e130441329a dcache_line_size r2, r3 sub r3, r2, #1 bic r0, r0, r3 - -From d3c2586371e3d21fa37fc6a5ed62041769ceea9a Mon Sep 17 00:00:00 2001 -From: Olivier Schonken -Date: Mon, 28 Aug 2017 10:52:32 +0200 -Subject: [PATCH 172/199] Fix DTB overlay compilation for arm64 broadcom - -The dts-dirs variable was overwritten by the assignment of the -stingray directory after the overlays directory, thus no overlays -were being built - -Signed-off-by: Olivier Schonken ---- - arch/arm64/boot/dts/broadcom/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/arch/arm64/boot/dts/broadcom/Makefile b/arch/arm64/boot/dts/broadcom/Makefile -index 97af2ececc52ca3aad7b84dc2fdb5c269a45bde0..3b76320112196a1fce7a0941c696fd1ec43b817f 100644 ---- a/arch/arm64/boot/dts/broadcom/Makefile -+++ b/arch/arm64/boot/dts/broadcom/Makefile -@@ -11,7 +11,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2710-rpi-3-b.dtb - - dts-dirs += ../overlays - --dts-dirs := stingray -+dts-dirs += stingray - always := $(dtb-y) - subdir-y := $(dts-dirs) - clean-files := *.dtb - -From f3a57e732ea6da07452519cee968db4f1bc5820f Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Fri, 25 Aug 2017 19:18:26 +0100 -Subject: [PATCH 173/199] vcsm: Provide new ioctl to clean/invalidate a 2D - block - ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 92 ++++++++++++++++++++++++++++++++-- - include/linux/broadcom/vmcs_sm_ioctl.h | 16 ++++++ - 2 files changed, 105 insertions(+), 3 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index fd2ca788dcd56b1702454d71b7bedd4203179500..d49e39566d521c95a96375c556516e444d52b6a0 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -142,6 +142,7 @@ struct SM_RESOURCE_T { - struct list_head map_list; /* Maps associated with a resource. */ - - struct SM_PRIV_DATA_T *private; -+ bool map; /* whether to map pages up front */ - }; - - /* Private file data associated with each opened device. -@@ -1376,6 +1377,20 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - vcsm_vma_open(vma); - resource->res_stats[MAP]++; - vmcs_sm_release_resource(resource, 0); -+ -+ if (resource->map) { -+ /* We don't use vmf->pgoff since that has the fake offset */ -+ unsigned long addr; -+ for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) { -+ /* Finally, remap it */ -+ unsigned long pfn = (unsigned long)resource->res_base_mem & 0x3FFFFFFF; -+ pfn += mm_vc_mem_phys_addr; -+ pfn += addr - vma->vm_start; -+ pfn >>= PAGE_SHIFT; -+ ret = vm_insert_pfn(vma, addr, pfn); -+ } -+ } -+ - return 0; - - error: -@@ -1394,10 +1409,18 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - struct SM_RESOURCE_T *resource; - VC_SM_ALLOC_T alloc = { 0 }; - VC_SM_ALLOC_RESULT_T result = { 0 }; -+ enum vmcs_sm_cache_e cached = ioparam->cached; -+ bool map = false; -+ -+ /* flag to requst buffer is mapped up front, rather than lazily */ -+ if (cached & 0x80 ) { -+ map = true; -+ cached &= ~0x80; -+ } - - /* Setup our allocation parameters */ -- alloc.type = ((ioparam->cached == VMCS_SM_CACHE_VC) -- || (ioparam->cached == -+ alloc.type = ((cached == VMCS_SM_CACHE_VC) -+ || (cached == - VMCS_SM_CACHE_BOTH)) ? VC_SM_ALLOC_CACHED : - VC_SM_ALLOC_NON_CACHED; - alloc.base_unit = ioparam->size; -@@ -1455,7 +1478,8 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - resource->res_handle = result.res_handle; - resource->res_base_mem = result.res_mem; - resource->res_size = alloc.base_unit * alloc.num_unit; -- resource->res_cached = ioparam->cached; -+ resource->res_cached = cached; -+ resource->map = map; - - /* Kernel/user GUID. This global identifier is used for mmap'ing the - * allocated region from user space, it is passed as the mmap'ing -@@ -2790,6 +2814,68 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - } - } - break; -+ /* Flush/Invalidate the cache for a given mapping. */ -+ case VMCS_SM_CMD_CLEAN_INVALID2: -+ { -+ int i, j; -+ struct vmcs_sm_ioctl_clean_invalid2 ioparam; -+ struct vmcs_sm_ioctl_clean_invalid_block *block = NULL; -+ -+ /* Get parameter data. */ -+ if (copy_from_user(&ioparam, -+ (void *)arg, sizeof(ioparam)) != 0) { -+ pr_err("[%s]: failed to copy-from-user header for cmd %x\n", -+ __func__, cmdnr); -+ ret = -EFAULT; -+ goto out; -+ } -+ block = kzalloc(ioparam.op_count * sizeof(struct vmcs_sm_ioctl_clean_invalid_block), GFP_KERNEL); -+ if (!block) { -+ ret = -EFAULT; -+ goto out; -+ } -+ if (copy_from_user(block, -+ (void *)(arg + sizeof(ioparam)), ioparam.op_count * sizeof(struct vmcs_sm_ioctl_clean_invalid_block)) != 0) { -+ pr_err("[%s]: failed to copy-from-user payload for cmd %x\n", -+ __func__, cmdnr); -+ ret = -EFAULT; -+ goto out; -+ } -+ -+ for (i=0; iblock_count; ++j) { -+ -+ -+ extern void v6_dma_inv_range(void *start, void *end); -+ extern void v6_dma_clean_range(void *start, void *end); -+ unsigned long base = (unsigned long)op->start_address + j * op->inter_block_stride; -+ unsigned long end = base + op->block_size; -+ /* L1/L2 cache clean */ -+ if (op->invalidate_mode & 2) { -+#if defined(CONFIG_CPU_CACHE_V7) -+ extern void v7_dma_clean_range(void *start, void *end); -+ v7_dma_clean_range((void *)base, (void *)end); -+#elif defined(CONFIG_CPU_CACHE_V6) -+ extern void v6_dma_clean_range(void *start, void *end); -+ v6_dma_clean_range((void *)base, (void *)end); -+#endif -+ /* L1/L2 cache invalidate */ -+ } -+ if (op->invalidate_mode & 1) { -+#if defined(CONFIG_CPU_CACHE_V7) -+ extern void v7_dma_inv_range(void *start, void *end); -+ v7_dma_inv_range((void *)base, (void *)end); -+#elif defined(CONFIG_CPU_CACHE_V6) -+ extern void v6_dma_inv_range(void *start, void *end); -+ v6_dma_inv_range((void *)base, (void *)end); -+#endif -+ } -+ } -+ } -+ kfree(block); -+ } -+ break; - - default: - { -diff --git a/include/linux/broadcom/vmcs_sm_ioctl.h b/include/linux/broadcom/vmcs_sm_ioctl.h -index 334f36d0d697b047df2922b5f2db67f38cf76564..2de7f1f41070689c99cad3bd43d117458549cb51 100644 ---- a/include/linux/broadcom/vmcs_sm_ioctl.h -+++ b/include/linux/broadcom/vmcs_sm_ioctl.h -@@ -62,6 +62,7 @@ enum vmcs_sm_cmd_e { - VMCS_SM_CMD_HOST_WALK_PID_MAP, - - VMCS_SM_CMD_CLEAN_INVALID, -+ VMCS_SM_CMD_CLEAN_INVALID2, - - VMCS_SM_CMD_LAST /* Do no delete */ - }; -@@ -175,6 +176,18 @@ struct vmcs_sm_ioctl_clean_invalid { - } s[8]; - }; - -+struct vmcs_sm_ioctl_clean_invalid2 { -+ uint8_t op_count; -+ uint8_t zero[3]; -+ struct vmcs_sm_ioctl_clean_invalid_block { -+ uint16_t invalidate_mode; -+ uint16_t block_count; -+ void * start_address; -+ uint32_t block_size; -+ uint32_t inter_block_stride; -+ } s[0]; -+}; -+ - /* IOCTL numbers */ - #define VMCS_SM_IOCTL_MEM_ALLOC\ - _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_ALLOC,\ -@@ -206,6 +219,9 @@ struct vmcs_sm_ioctl_clean_invalid { - #define VMCS_SM_IOCTL_MEM_CLEAN_INVALID\ - _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_CLEAN_INVALID,\ - struct vmcs_sm_ioctl_clean_invalid) -+#define VMCS_SM_IOCTL_MEM_CLEAN_INVALID2\ -+ _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_CLEAN_INVALID2,\ -+ struct vmcs_sm_ioctl_clean_invalid2) - - #define VMCS_SM_IOCTL_SIZE_USR_HDL\ - _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_SIZE_USR_HANDLE,\ - -From b9111ab4c7fe798b294e9485630750431b5dd5fa Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Wed, 15 Feb 2017 11:16:05 +0000 -Subject: [PATCH 174/199] VCSM: Specify pointers in IPC msgs as uint32_t - -Pointers were specified as void* which will fail -rather badly if the kernel is switched to 64 bit. -GPU wants 32 bit addresses, so use uint32_t and -cast whereever necessary. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_sm_defs.h | 12 ++++---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 52 +++++++++++++++++--------------- - 2 files changed, 33 insertions(+), 31 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_defs.h b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -index c4d5ff718a5ba9071ef87fa4c6cf632486c4d36f..6c19aac6dc9df90edb9432bc32e7477d532d3278 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_defs.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -@@ -88,7 +88,7 @@ typedef struct { - /* Resource handle */ - uint32_t res_handle; - /* Pointer to resource buffer */ -- void *res_mem; -+ uint32_t res_mem; - /* Resource base size (bytes) */ - uint32_t res_base_size; - /* Resource number */ -@@ -101,7 +101,7 @@ typedef struct { - /* Resource handle (returned from alloc) */ - uint32_t res_handle; - /* Resource buffer (returned from alloc) */ -- void *res_mem; -+ uint32_t res_mem; - - } VC_SM_FREE_T; - -@@ -110,7 +110,7 @@ typedef struct { - /* Resource handle (returned from alloc) */ - uint32_t res_handle; - /* Resource buffer (returned from alloc) */ -- void *res_mem; -+ uint32_t res_mem; - - } VC_SM_LOCK_UNLOCK_T; - -@@ -119,7 +119,7 @@ typedef struct { - /* Resource handle (returned from alloc) */ - uint32_t res_handle; - /* Resource buffer (returned from alloc) */ -- void *res_mem; -+ uint32_t res_mem; - /* Resource *new* size requested (bytes) */ - uint32_t res_new_size; - -@@ -133,10 +133,10 @@ typedef struct { - /* Resource handle */ - uint32_t res_handle; - /* Pointer to resource buffer */ -- void *res_mem; -+ uint32_t res_mem; - /* Pointer to former resource buffer if the memory - * was reallocated */ -- void *res_old_mem; -+ uint32_t res_old_mem; - - } VC_SM_LOCK_RESULT_T; - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index d49e39566d521c95a96375c556516e444d52b6a0..1afea701625157e9d9bc9570240c0b1afb186f56 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -877,7 +877,7 @@ static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) - */ - if (resource->res_handle) { - VC_SM_FREE_T free = { -- resource->res_handle, resource->res_base_mem -+ resource->res_handle, (uint32_t)resource->res_base_mem - }; - int status = vc_vchi_sm_free(sm_state->sm_handle, &free, - &private->int_trans_id); -@@ -1136,17 +1136,17 @@ static int vcsm_vma_fault(struct vm_fault *vmf) - int status; - - lock_unlock.res_handle = resource->res_handle; -- lock_unlock.res_mem = resource->res_base_mem; -+ lock_unlock.res_mem = (uint32_t)resource->res_base_mem; - - pr_debug("[%s]: attempt to lock data - hdl %x, base address %p\n", -- __func__, lock_unlock.res_handle, lock_unlock.res_mem); -+ __func__, lock_unlock.res_handle, -+ (void *)lock_unlock.res_mem); - - /* Lock the videocore allocated resource. - */ - status = vc_vchi_sm_lock(sm_state->sm_handle, - &lock_unlock, &lock_result, 0); -- if ((status != 0) || -- ((status == 0) && (lock_result.res_mem == NULL))) { -+ if (status || !lock_result.res_mem) { - pr_err("[%s]: failed to lock memory on videocore (status: %u)\n", - __func__, status); - resource->res_stats[LOCK_FAIL]++; -@@ -1162,10 +1162,10 @@ static int vcsm_vma_fault(struct vm_fault *vmf) - - /* Keep track of the new base memory. - */ -- if ((lock_result.res_mem != NULL) && -- (lock_result.res_old_mem != NULL) && -+ if (lock_result.res_mem && -+ lock_result.res_old_mem && - (lock_result.res_mem != lock_result.res_old_mem)) { -- resource->res_base_mem = lock_result.res_mem; -+ resource->res_base_mem = (void *)lock_result.res_mem; - } - } - -@@ -1464,7 +1464,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - private->restart_sys = -EINTR; - private->int_action = VC_SM_MSG_TYPE_ALLOC; - goto error; -- } else if (status != 0 || (status == 0 && result.res_mem == NULL)) { -+ } else if (status != 0 || !result.res_mem) { - pr_err("[%s]: failed to allocate memory on videocore (status: %u, trans_id: %u)\n", - __func__, status, private->int_trans_id); - ret = -ENOMEM; -@@ -1476,7 +1476,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - */ - resource->private = private; - resource->res_handle = result.res_handle; -- resource->res_base_mem = result.res_mem; -+ resource->res_base_mem = (void *)result.res_mem; - resource->res_size = alloc.base_unit * alloc.num_unit; - resource->res_cached = cached; - resource->map = map; -@@ -1654,11 +1654,12 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - } - - resize.res_handle = resource->res_handle; -- resize.res_mem = resource->res_base_mem; -+ resize.res_mem = (uint32_t)resource->res_base_mem; - resize.res_new_size = ioparam->new_size; - - pr_debug("[%s]: attempt to resize data - guid %x, hdl %x, base address %p\n", -- __func__, ioparam->handle, resize.res_handle, resize.res_mem); -+ __func__, ioparam->handle, resize.res_handle, -+ (void *)resize.res_mem); - - /* Resize the videocore allocated resource. - */ -@@ -1671,7 +1672,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - private->restart_sys = -EINTR; - private->int_action = VC_SM_MSG_TYPE_RESIZE; - goto error; -- } else if (status != 0) { -+ } else if (status) { - pr_err("[%s]: failed to resize memory on videocore (status: %u, trans_id: %u)\n", - __func__, status, private->int_trans_id); - ret = -EPERM; -@@ -1729,14 +1730,14 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - } - - lock.res_handle = resource->res_handle; -- lock.res_mem = resource->res_base_mem; -+ lock.res_mem = (uint32_t)resource->res_base_mem; - - /* Take the lock and get the address to be mapped. - */ - if (vc_addr == 0) { - pr_debug("[%s]: attempt to lock data - guid %x, hdl %x, base address %p\n", - __func__, ioparam->handle, lock.res_handle, -- lock.res_mem); -+ (void *)lock.res_mem); - - /* Lock the videocore allocated resource. - */ -@@ -1749,8 +1750,8 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - private->restart_sys = -EINTR; - private->int_action = VC_SM_MSG_TYPE_LOCK; - goto error; -- } else if (status != 0 || -- (status == 0 && result.res_mem == NULL)) { -+ } else if (status || -+ (!status && !(void *)result.res_mem)) { - pr_err("[%s]: failed to lock memory on videocore (status: %u, trans_id: %u)\n", - __func__, status, private->int_trans_id); - ret = -EPERM; -@@ -1759,8 +1760,8 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - } - - pr_debug("[%s]: succeed to lock data - hdl %x, base address %p (%p), ref-cnt %d\n", -- __func__, lock.res_handle, result.res_mem, -- lock.res_mem, resource->lock_count); -+ __func__, lock.res_handle, (void *)result.res_mem, -+ (void *)lock.res_mem, resource->lock_count); - } - /* Lock assumed taken already, address to be mapped is known. - */ -@@ -1773,10 +1774,10 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - /* Keep track of the new base memory allocation if it has changed. - */ - if ((vc_addr == 0) && -- (result.res_mem != NULL) && -- (result.res_old_mem != NULL) && -+ ((void *)result.res_mem) && -+ ((void *)result.res_old_mem) && - (result.res_mem != result.res_old_mem)) { -- resource->res_base_mem = result.res_mem; -+ resource->res_base_mem = (void *)result.res_mem; - - /* Kernel allocated resources. - */ -@@ -1901,10 +1902,11 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - } - - unlock.res_handle = resource->res_handle; -- unlock.res_mem = resource->res_base_mem; -+ unlock.res_mem = (uint32_t)resource->res_base_mem; - - pr_debug("[%s]: attempt to unlock data - guid %x, hdl %x, base address %p\n", -- __func__, ioparam->handle, unlock.res_handle, unlock.res_mem); -+ __func__, ioparam->handle, unlock.res_handle, -+ (void *)unlock.res_mem); - - /* User space allocated resources. - */ -@@ -2039,7 +2041,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - } - - pr_debug("[%s]: success to unlock data - hdl %x, base address %p, ref-cnt %d\n", -- __func__, unlock.res_handle, unlock.res_mem, -+ __func__, unlock.res_handle, (void *)unlock.res_mem, - resource->lock_count); - - error: - -From 27e934896b9c0685c6d49f8d3f4fac692bcd6cb5 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 19 May 2017 14:29:12 +0100 -Subject: [PATCH 175/199] vcsm: code-style: Fix comment indentation - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_vchi_sm.h | 58 +++++++++++++++++++------------- - 1 file changed, 34 insertions(+), 24 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -index 5e279f5a95fac7227cea15941bf0570ddc2b0886..f8e555dc30074e7ff226cf34a96aa30a34176775 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -@@ -19,63 +19,73 @@ - - #include "vc_sm_defs.h" - --/* Forward declare. -+/* -+ * Forward declare. - */ - typedef struct sm_instance *VC_VCHI_SM_HANDLE_T; - --/* Initialize the shared memory service, opens up vchi connection to talk to it. --*/ -+/* -+ * Initialize the shared memory service, opens up vchi connection to talk to it. -+ */ - VC_VCHI_SM_HANDLE_T vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, - VCHI_CONNECTION_T **vchi_connections, - uint32_t num_connections); - --/* Terminates the shared memory service. --*/ -+/* -+ * Terminates the shared memory service. -+ */ - int vc_vchi_sm_stop(VC_VCHI_SM_HANDLE_T *handle); - --/* Ask the shared memory service to allocate some memory on videocre and --** return the result of this allocation (which upon success will be a pointer --** to some memory in videocore space). --*/ -+/* -+ * Ask the shared memory service to allocate some memory on videocre and -+ * return the result of this allocation (which upon success will be a pointer -+ * to some memory in videocore space). -+ */ - int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, - VC_SM_ALLOC_T *alloc, - VC_SM_ALLOC_RESULT_T *alloc_result, uint32_t *trans_id); - --/* Ask the shared memory service to free up some memory that was previously --** allocated by the vc_vchi_sm_alloc function call. --*/ -+/* -+ * Ask the shared memory service to free up some memory that was previously -+ * allocated by the vc_vchi_sm_alloc function call. -+ */ - int vc_vchi_sm_free(VC_VCHI_SM_HANDLE_T handle, - VC_SM_FREE_T *free, uint32_t *trans_id); - --/* Ask the shared memory service to lock up some memory that was previously --** allocated by the vc_vchi_sm_alloc function call. -+/* -+ * Ask the shared memory service to lock up some memory that was previously -+ * allocated by the vc_vchi_sm_alloc function call. - */ - int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, - VC_SM_LOCK_UNLOCK_T *lock_unlock, - VC_SM_LOCK_RESULT_T *lock_result, uint32_t *trans_id); - --/* Ask the shared memory service to unlock some memory that was previously --** allocated by the vc_vchi_sm_alloc function call. -+/* -+ * Ask the shared memory service to unlock some memory that was previously -+ * allocated by the vc_vchi_sm_alloc function call. - */ - int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, - VC_SM_LOCK_UNLOCK_T *lock_unlock, - uint32_t *trans_id, uint8_t wait_reply); - --/* Ask the shared memory service to resize some memory that was previously --** allocated by the vc_vchi_sm_alloc function call. -+/* -+ * Ask the shared memory service to resize some memory that was previously -+ * allocated by the vc_vchi_sm_alloc function call. - */ - int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, - VC_SM_RESIZE_T *resize, uint32_t *trans_id); - --/* Walk the allocated resources on the videocore side, the allocation will --** show up in the log. This is purely for debug/information and takes no --** specific actions. -+/* -+ * Walk the allocated resources on the videocore side, the allocation will -+ * show up in the log. This is purely for debug/information and takes no -+ * specific actions. - */ - int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle); - --/* Clean up following a previously interrupted action which left the system --** in a bad state of some sort. --*/ -+/* -+ * Clean up following a previously interrupted action which left the system -+ * in a bad state of some sort. -+ */ - int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, - VC_SM_ACTION_CLEAN_T *action_clean); - - -From 4d48640616c8d5f0f7800ea60fd427dacef89c3e Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 25 Aug 2017 15:58:57 +0100 -Subject: [PATCH 176/199] vcsm: Convert to loading via device tree. - -Signed-off-by: Dave Stevenson ---- - arch/arm/boot/dts/bcm2708-rpi.dtsi | 6 ++++ - drivers/char/broadcom/vc_sm/vmcs_sm.c | 53 ++++++++++++++++++++++++----------- - 2 files changed, 43 insertions(+), 16 deletions(-) - -diff --git a/arch/arm/boot/dts/bcm2708-rpi.dtsi b/arch/arm/boot/dts/bcm2708-rpi.dtsi -index 8cc83a350d02bb485f7a4fcb129df9e00fb3f958..f88b844f0aff82742966fd820f6f69cf25c2dfab 100644 ---- a/arch/arm/boot/dts/bcm2708-rpi.dtsi -+++ b/arch/arm/boot/dts/bcm2708-rpi.dtsi -@@ -74,6 +74,12 @@ - firmware = <&firmware>; - }; - -+ vcsm: vcsm { -+ compatible = "raspberrypi,bcm2835-vcsm"; -+ firmware = <&firmware>; -+ status = "okay"; -+ }; -+ - thermal: thermal@7e212000 { - #thermal-sensor-cells = <0>; - status = "okay"; -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 1afea701625157e9d9bc9570240c0b1afb186f56..eb0d3f8a8c27863a5469d0ac224aab65145e7560 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -27,6 +27,8 @@ - #include - #include - #include -+#include -+#include - #include - #include - #include -@@ -45,6 +47,7 @@ - /* ---- Private Constants and Types --------------------------------------- */ - - #define DEVICE_NAME "vcsm" -+#define DRIVER_NAME "bcm2835-vcsm" - #define DEVICE_MINOR 0 - - #define VC_SM_DIR_ROOT_NAME "vc-smem" -@@ -165,6 +168,7 @@ struct SM_PRIV_DATA_T { - /* Global state information. - */ - struct SM_STATE_T { -+ struct platform_device *pdev; - VC_VCHI_SM_HANDLE_T sm_handle; /* Handle for videocore service. */ - struct dentry *dir_root; /* Debug fs entries root. */ - struct dentry *dir_alloc; /* Debug fs entries allocations. */ -@@ -3000,18 +3004,6 @@ static void vc_sm_connected_init(void) - - pr_info("[%s]: start\n", __func__); - -- /* Allocate memory for the state structure. -- */ -- sm_state = kzalloc(sizeof(struct SM_STATE_T), GFP_KERNEL); -- if (sm_state == NULL) { -- pr_err("[%s]: failed to allocate memory\n", __func__); -- ret = -ENOMEM; -- goto out; -- } -- -- mutex_init(&sm_state->lock); -- mutex_init(&sm_state->map_lock); -- - /* Initialize and create a VCHI connection for the shared memory service - ** running on videocore. - */ -@@ -3104,15 +3096,23 @@ static void vc_sm_connected_init(void) - } - - /* Driver loading. */ --static int __init vc_sm_init(void) -+static int bcm2835_vcsm_probe(struct platform_device *pdev) - { - pr_info("vc-sm: Videocore shared memory driver\n"); -+ -+ sm_state = kzalloc(sizeof(*sm_state), GFP_KERNEL); -+ if (!sm_state) -+ return -ENOMEM; -+ sm_state->pdev = pdev; -+ mutex_init(&sm_state->lock); -+ mutex_init(&sm_state->map_lock); -+ - vchiq_add_connected_callback(vc_sm_connected_init); - return 0; - } - - /* Driver unloading. */ --static void __exit vc_sm_exit(void) -+static int bcm2835_vcsm_remove(struct platform_device *pdev) - { - pr_debug("[%s]: start\n", __func__); - if (sm_inited) { -@@ -3135,6 +3135,7 @@ static void __exit vc_sm_exit(void) - } - - pr_debug("[%s]: end\n", __func__); -+ return 0; - } - - #if defined(__KERNEL__) -@@ -3302,8 +3303,28 @@ int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, - EXPORT_SYMBOL_GPL(vc_sm_map); - #endif - --late_initcall(vc_sm_init); --module_exit(vc_sm_exit); -+/* -+ * Register the driver with device tree -+ */ -+ -+static const struct of_device_id bcm2835_vcsm_of_match[] = { -+ {.compatible = "raspberrypi,bcm2835-vcsm",}, -+ { /* sentinel */ }, -+}; -+ -+MODULE_DEVICE_TABLE(of, bcm2835_vcsm_of_match); -+ -+static struct platform_driver bcm2835_vcsm_driver = { -+ .probe = bcm2835_vcsm_probe, -+ .remove = bcm2835_vcsm_remove, -+ .driver = { -+ .name = DRIVER_NAME, -+ .owner = THIS_MODULE, -+ .of_match_table = bcm2835_vcsm_of_match, -+ }, -+}; -+ -+module_platform_driver(bcm2835_vcsm_driver); - - MODULE_AUTHOR("Broadcom"); - MODULE_DESCRIPTION("VideoCore SharedMemory Driver"); - -From b99343baef75676dc3192f9fc71eb6a703cbb4ae Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Wed, 15 Feb 2017 11:17:44 +0000 -Subject: [PATCH 177/199] VCSM: New option to import a DMABUF for VPU use - -Takes a dmabuf, and then calls over to the VPU to wrap -it into a suitable handle. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_sm_defs.h | 57 ++++++- - drivers/char/broadcom/vc_sm/vc_sm_knl.h | 21 ++- - drivers/char/broadcom/vc_sm/vc_vchi_sm.c | 9 ++ - drivers/char/broadcom/vc_sm/vc_vchi_sm.h | 7 + - drivers/char/broadcom/vc_sm/vmcs_sm.c | 269 ++++++++++++++++++++++++++++++- - include/linux/broadcom/vmcs_sm_ioctl.h | 18 ++- - 6 files changed, 359 insertions(+), 22 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_defs.h b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -index 6c19aac6dc9df90edb9432bc32e7477d532d3278..bf057969644546d8f036044aa14d6606173b6a35 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_defs.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -@@ -26,8 +26,9 @@ - /* Resource name maximum size */ - #define VC_SM_RESOURCE_NAME 32 - --/* All message types supported for HOST->VC direction */ - typedef enum { -+ /* Message types supported for HOST->VC direction */ -+ - /* Allocate shared memory block */ - VC_SM_MSG_TYPE_ALLOC, - /* Lock allocated shared memory block */ -@@ -45,6 +46,21 @@ typedef enum { - - /* A previously applied action will need to be reverted */ - VC_SM_MSG_TYPE_ACTION_CLEAN, -+ -+ /* -+ * Import a physical address and wrap into a MEM_HANDLE_T. -+ * Release with VC_SM_MSG_TYPE_FREE. -+ */ -+ VC_SM_MSG_TYPE_IMPORT, -+ -+ /* Message types supported for VC->HOST direction */ -+ -+ /* -+ * VC has finished with an imported memory allocation. -+ * Release any Linux reference counts on the underlying block. -+ */ -+ VC_SM_MSG_TYPE_RELEASED, -+ - VC_SM_MSG_TYPE_MAX - } VC_SM_MSG_TYPE; - -@@ -165,6 +181,41 @@ typedef struct { - - } VC_SM_FREE_ALL_T; - -+/* Request to import memory (HOST->VC) */ -+struct vc_sm_import { -+ /* type of memory to allocate */ -+ VC_SM_ALLOC_TYPE_T type; -+ /* pointer to the VC (ie physical) address of the allocated memory */ -+ uint32_t addr; -+ /* size of buffer */ -+ uint32_t size; -+ /* opaque handle returned in RELEASED messages */ -+ int32_t kernel_id; -+ /* Allocator identifier */ -+ uint32_t allocator; -+ /* resource name (for easier tracking on vc side) */ -+ char name[VC_SM_RESOURCE_NAME]; -+}; -+ -+/* Result of a requested memory import (VC->HOST) */ -+struct vc_sm_import_result { -+ /* Transaction identifier */ -+ uint32_t trans_id; -+ -+ /* Resource handle */ -+ uint32_t res_handle; -+}; -+ -+/* Notification that VC has finished with an allocation (VC->HOST) */ -+struct vc_sm_released { -+ /* pointer to the VC (ie physical) address of the allocated memory */ -+ uint32_t addr; -+ /* size of buffer */ -+ uint32_t size; -+ /* opaque handle returned in RELEASED messages */ -+ int32_t kernel_id; -+}; -+ - /* Union of ALL messages */ - typedef union { - VC_SM_ALLOC_T alloc; -@@ -175,7 +226,9 @@ typedef union { - VC_SM_LOCK_RESULT_T lock_result; - VC_SM_RESULT_T result; - VC_SM_FREE_ALL_T free_all; -- -+ struct vc_sm_import import; -+ struct vc_sm_import_result import_result; -+ struct vc_sm_released released; - } VC_SM_MSG_UNION_T; - - #endif /* __VC_SM_DEFS_H__INCLUDED__ */ -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_knl.h b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -index 965f9a209a025202fea8065d3947c36f4fa43d0a..31050d3eb242b744c1ca43d6672d63b8439f7bc5 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_knl.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -@@ -26,30 +26,27 @@ typedef enum { - - } VC_SM_LOCK_CACHE_MODE_T; - --/* Allocate a shared memory handle and block. --*/ -+/* Allocate a shared memory handle and block. */ - int vc_sm_alloc(VC_SM_ALLOC_T *alloc, int *handle); - --/* Free a previously allocated shared memory handle and block. --*/ -+/* Free a previously allocated shared memory handle and block. */ - int vc_sm_free(int handle); - --/* Lock a memory handle for use by kernel. --*/ -+/* Lock a memory handle for use by kernel. */ - int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, - long unsigned int *data); - --/* Unlock a memory handle in use by kernel. --*/ -+/* Unlock a memory handle in use by kernel. */ - int vc_sm_unlock(int handle, int flush, int no_vc_unlock); - --/* Get an internal resource handle mapped from the external one. --*/ -+/* Get an internal resource handle mapped from the external one. */ - int vc_sm_int_handle(int handle); - --/* Map a shared memory region for use by kernel. --*/ -+/* Map a shared memory region for use by kernel. */ - int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, - long unsigned int *data); - -+/* Import a block of memory into the GPU space. */ -+int vc_sm_import_dmabuf(struct dma_buf *dmabuf, int *handle); -+ - #endif /* __VC_SM_KNL_H__INCLUDED__ */ -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -index 76abd126c4617b6310fcf0ebd7ab1d5f73a18a70..53fc11a9d5d741ec6a7e55b4d1934c9c43a6df8c 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -@@ -497,3 +497,12 @@ int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, VC_SM_ACTION_CLEAN_T *msg) - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_ACTION_CLEAN, - msg, sizeof(*msg), 0, 0, 0, 0); - } -+ -+int vc_vchi_sm_import(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_import *msg, -+ struct vc_sm_import_result *result, -+ uint32_t *cur_trans_id) -+{ -+ return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_IMPORT, -+ msg, sizeof(*msg), result, sizeof(*result), -+ cur_trans_id, 1); -+} -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -index f8e555dc30074e7ff226cf34a96aa30a34176775..562217831fa744db99d94295c1c5a46f3a4780fb 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -@@ -89,4 +89,11 @@ int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle); - int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, - VC_SM_ACTION_CLEAN_T *action_clean); - -+/* -+ * Import a contiguous block of memory and wrap it in a GPU MEM_HANDLE_T. -+ */ -+int vc_vchi_sm_import(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_import *msg, -+ struct vc_sm_import_result *result, -+ uint32_t *cur_trans_id); -+ - #endif /* __VC_VCHI_SM_H__INCLUDED__ */ -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index eb0d3f8a8c27863a5469d0ac224aab65145e7560..520f343f3f4b828f3045fc4ff3fb0d8a68bb1f9d 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -69,6 +70,7 @@ enum SM_STATS_T { - MAP, - FLUSH, - INVALID, -+ IMPORT, - - END_ATTEMPT, - -@@ -80,6 +82,7 @@ enum SM_STATS_T { - MAP_FAIL, - FLUSH_FAIL, - INVALID_FAIL, -+ IMPORT_FAIL, - - END_ALL, - -@@ -93,6 +96,7 @@ static const char *const sm_stats_human_read[] = { - "Map", - "Cache Flush", - "Cache Invalidate", -+ "Import", - }; - - typedef int (*VC_SM_SHOW) (struct seq_file *s, void *v); -@@ -144,6 +148,12 @@ struct SM_RESOURCE_T { - uint8_t map_count; /* Counter of mappings for this resource. */ - struct list_head map_list; /* Maps associated with a resource. */ - -+ /* DMABUF related fields */ -+ struct dma_buf *dma_buf; -+ struct dma_buf_attachment *attach; -+ struct sg_table *sgt; -+ dma_addr_t dma_addr; -+ - struct SM_PRIV_DATA_T *private; - bool map; /* whether to map pages up front */ - }; -@@ -500,7 +510,9 @@ static void vmcs_sm_remove_map(struct SM_STATE_T *state, - static int vc_sm_global_state_show(struct seq_file *s, void *v) - { - struct sm_mmap *map = NULL; -+ struct SM_RESOURCE_T *resource = NULL; - int map_count = 0; -+ int resource_count = 0; - - if (sm_state == NULL) - return 0; -@@ -512,7 +524,41 @@ static int vc_sm_global_state_show(struct seq_file *s, void *v) - */ - - mutex_lock(&(sm_state->map_lock)); -+ seq_puts(s, "\nResources\n"); -+ if (!list_empty(&sm_state->resource_list)) { -+ list_for_each_entry(resource, &sm_state->resource_list, -+ global_resource_list) { -+ resource_count++; -+ -+ seq_printf(s, "\nResource %p\n", -+ resource); -+ seq_printf(s, " PID %u\n", -+ resource->pid); -+ seq_printf(s, " RES_GUID 0x%x\n", -+ resource->res_guid); -+ seq_printf(s, " LOCK_COUNT %u\n", -+ resource->lock_count); -+ seq_printf(s, " REF_COUNT %u\n", -+ resource->ref_count); -+ seq_printf(s, " res_handle 0x%X\n", -+ resource->res_handle); -+ seq_printf(s, " res_base_mem %p\n", -+ resource->res_base_mem); -+ seq_printf(s, " SIZE %d\n", -+ resource->res_size); -+ seq_printf(s, " DMABUF %p\n", -+ resource->dma_buf); -+ seq_printf(s, " ATTACH %p\n", -+ resource->attach); -+ seq_printf(s, " SGT %p\n", -+ resource->sgt); -+ seq_printf(s, " DMA_ADDR 0x%08X\n", -+ resource->dma_addr); -+ } -+ } -+ seq_printf(s, "\n\nTotal resource count: %d\n\n", resource_count); - -+ seq_puts(s, "\nMappings\n"); - if (!list_empty(&sm_state->map_list)) { - list_for_each_entry(map, &sm_state->map_list, map_list) { - map_count++; -@@ -527,6 +573,8 @@ static int vc_sm_global_state_show(struct seq_file *s, void *v) - map->res_usr_hdl); - seq_printf(s, " USR-ADDR 0x%lx\n", - map->res_addr); -+ seq_printf(s, " SIZE %d\n", -+ map->resource->res_size); - } - } - -@@ -843,7 +891,8 @@ static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) - list_del(&resource->resource_list); - list_del(&resource->global_resource_list); - -- /* Walk the global resource list, find out if the resource is used -+ /* -+ * Walk the global resource list, find out if the resource is used - * somewhere else. In which case we don't want to delete it. - */ - list_for_each_entry(res_tmp, &sm_state->resource_list, -@@ -877,8 +926,7 @@ static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) - up_write(¤t->mm->mmap_sem); - } - -- /* Free up the videocore allocated resource. -- */ -+ /* Free up the videocore allocated resource. */ - if (resource->res_handle) { - VC_SM_FREE_T free = { - resource->res_handle, (uint32_t)resource->res_base_mem -@@ -893,13 +941,19 @@ static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) - } - } - -- /* Free up the shared resource. -- */ -+ if (resource->sgt) -+ dma_buf_unmap_attachment(resource->attach, resource->sgt, -+ DMA_BIDIRECTIONAL); -+ if (resource->attach) -+ dma_buf_detach(resource->dma_buf, resource->attach); -+ if (resource->dma_buf) -+ dma_buf_put(resource->dma_buf); -+ -+ /* Free up the shared resource. */ - if (resource->res_shared) - vmcs_sm_release_resource(resource->res_shared, 0); - -- /* Free up the local resource tracking this allocation. -- */ -+ /* Free up the local resource tracking this allocation. */ - vc_sm_resource_deceased(resource, force); - kfree(resource); - } -@@ -2055,6 +2109,137 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - return ret; - } - -+/* -+ * Import a contiguous block of memory to be shared with VC. -+ */ -+int vc_sm_ioctl_import_dmabuf(struct SM_PRIV_DATA_T *private, -+ struct vmcs_sm_ioctl_import_dmabuf *ioparam, -+ struct dma_buf *src_dma_buf) -+{ -+ int ret = 0; -+ int status; -+ struct SM_RESOURCE_T *resource = NULL; -+ struct vc_sm_import import = { 0 }; -+ struct vc_sm_import_result result = { 0 }; -+ struct dma_buf *dma_buf; -+ struct dma_buf_attachment *attach = NULL; -+ struct sg_table *sgt = NULL; -+ -+ /* Setup our allocation parameters */ -+ if (src_dma_buf) { -+ get_dma_buf(src_dma_buf); -+ dma_buf = src_dma_buf; -+ } else { -+ dma_buf = dma_buf_get(ioparam->dmabuf_fd); -+ } -+ if (IS_ERR(dma_buf)) -+ return PTR_ERR(dma_buf); -+ -+ attach = dma_buf_attach(dma_buf, &sm_state->pdev->dev); -+ if (IS_ERR(attach)) { -+ ret = PTR_ERR(attach); -+ goto error; -+ } -+ -+ sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL); -+ if (IS_ERR(sgt)) { -+ ret = PTR_ERR(sgt); -+ goto error; -+ } -+ -+ /* Verify that the address block is contiguous */ -+ if (sgt->nents != 1) { -+ ret = -ENOMEM; -+ goto error; -+ } -+ -+ import.type = ((ioparam->cached == VMCS_SM_CACHE_VC) || -+ (ioparam->cached == VMCS_SM_CACHE_BOTH)) ? -+ VC_SM_ALLOC_CACHED : VC_SM_ALLOC_NON_CACHED; -+ import.addr = (uint32_t)sg_dma_address(sgt->sgl); -+ import.size = sg_dma_len(sgt->sgl); -+ import.allocator = current->tgid; -+ -+ if (*ioparam->name) -+ memcpy(import.name, ioparam->name, sizeof(import.name) - 1); -+ else -+ memcpy(import.name, VMCS_SM_RESOURCE_NAME_DEFAULT, -+ sizeof(VMCS_SM_RESOURCE_NAME_DEFAULT)); -+ -+ pr_debug("[%s]: attempt to import \"%s\" data - type %u, addr %p, size %u\n", -+ __func__, import.name, import.type, -+ (void *)import.addr, import.size); -+ -+ /* Allocate local resource to track this allocation. */ -+ resource = kzalloc(sizeof(*resource), GFP_KERNEL); -+ if (!resource) { -+ ret = -ENOMEM; -+ goto error; -+ } -+ INIT_LIST_HEAD(&resource->map_list); -+ resource->ref_count++; -+ resource->pid = current->tgid; -+ -+ /* Allocate the videocore resource. */ -+ status = vc_vchi_sm_import(sm_state->sm_handle, &import, &result, -+ &private->int_trans_id); -+ if (status == -EINTR) { -+ pr_debug("[%s]: requesting import memory action restart (trans_id: %u)\n", -+ __func__, private->int_trans_id); -+ ret = -ERESTARTSYS; -+ private->restart_sys = -EINTR; -+ private->int_action = VC_SM_MSG_TYPE_IMPORT; -+ goto error; -+ } else if (status || !result.res_handle) { -+ pr_debug("[%s]: failed to import memory on videocore (status: %u, trans_id: %u)\n", -+ __func__, status, private->int_trans_id); -+ ret = -ENOMEM; -+ resource->res_stats[ALLOC_FAIL]++; -+ goto error; -+ } -+ -+ /* Keep track of the resource we created. -+ */ -+ resource->private = private; -+ resource->res_handle = result.res_handle; -+ resource->res_size = import.size; -+ resource->res_cached = ioparam->cached; -+ -+ resource->dma_buf = dma_buf; -+ resource->attach = attach; -+ resource->sgt = sgt; -+ resource->dma_addr = sg_dma_address(sgt->sgl); -+ -+ /* Kernel/user GUID. This global identifier is used for mmap'ing the -+ * allocated region from user space, it is passed as the mmap'ing -+ * offset, we use it to 'hide' the videocore handle/address. -+ */ -+ mutex_lock(&sm_state->lock); -+ resource->res_guid = ++sm_state->guid; -+ mutex_unlock(&sm_state->lock); -+ resource->res_guid <<= PAGE_SHIFT; -+ -+ vmcs_sm_add_resource(private, resource); -+ -+ /* We're done */ -+ resource->res_stats[IMPORT]++; -+ ioparam->handle = resource->res_guid; -+ return 0; -+ -+error: -+ resource->res_stats[IMPORT_FAIL]++; -+ if (resource) { -+ vc_sm_resource_deceased(resource, 1); -+ kfree(resource); -+ } -+ if (sgt) -+ dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL); -+ if (attach) -+ dma_buf_detach(dma_buf, attach); -+ dma_buf_put(dma_buf); -+ return ret; -+} -+ - /* Handle control from host. */ - static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - { -@@ -2166,6 +2351,40 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - } - break; - -+ case VMCS_SM_CMD_IMPORT_DMABUF: -+ { -+ struct vmcs_sm_ioctl_import_dmabuf ioparam; -+ -+ /* Get the parameter data. -+ */ -+ if (copy_from_user -+ (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { -+ pr_err("[%s]: failed to copy-from-user for cmd %x\n", -+ __func__, cmdnr); -+ ret = -EFAULT; -+ goto out; -+ } -+ -+ ret = vc_sm_ioctl_import_dmabuf(file_data, &ioparam, -+ NULL); -+ if (!ret && -+ (copy_to_user((void *)arg, -+ &ioparam, sizeof(ioparam)) != 0)) { -+ struct vmcs_sm_ioctl_free freeparam = { -+ ioparam.handle -+ }; -+ pr_err("[%s]: failed to copy-to-user for cmd %x\n", -+ __func__, cmdnr); -+ vc_sm_ioctl_free(file_data, &freeparam); -+ ret = -EFAULT; -+ } -+ -+ /* Done. -+ */ -+ goto out; -+ } -+ break; -+ - /* Lock (attempt to) *and* register a cache behavior change. - */ - case VMCS_SM_CMD_LOCK_CACHE: -@@ -3301,6 +3520,42 @@ int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, - return ret; - } - EXPORT_SYMBOL_GPL(vc_sm_map); -+ -+/* Import a dmabuf to be shared with VC. */ -+int vc_sm_import_dmabuf(struct dma_buf *dmabuf, int *handle) -+{ -+ struct vmcs_sm_ioctl_import_dmabuf ioparam = { 0 }; -+ int ret; -+ struct SM_RESOURCE_T *resource; -+ -+ /* Validate we can work with this device. */ -+ if (!sm_state || !dmabuf || !handle) { -+ pr_err("[%s]: invalid input\n", __func__); -+ return -EPERM; -+ } -+ -+ ioparam.cached = 0; -+ strcpy(ioparam.name, "KRNL DMABUF"); -+ -+ ret = vc_sm_ioctl_import_dmabuf(sm_state->data_knl, &ioparam, dmabuf); -+ -+ if (!ret) { -+ resource = vmcs_sm_acquire_resource(sm_state->data_knl, -+ ioparam.handle); -+ if (resource) { -+ resource->pid = 0; -+ vmcs_sm_release_resource(resource, 0); -+ -+ /* Assign valid handle at this time.*/ -+ *handle = ioparam.handle; -+ } else { -+ ret = -ENOMEM; -+ } -+ } -+ -+ return ret; -+} -+EXPORT_SYMBOL_GPL(vc_sm_import_dmabuf); - #endif - - /* -diff --git a/include/linux/broadcom/vmcs_sm_ioctl.h b/include/linux/broadcom/vmcs_sm_ioctl.h -index 2de7f1f41070689c99cad3bd43d117458549cb51..b75729d762f25aace133f7a008633b4094ae2de2 100644 ---- a/include/linux/broadcom/vmcs_sm_ioctl.h -+++ b/include/linux/broadcom/vmcs_sm_ioctl.h -@@ -64,7 +64,9 @@ enum vmcs_sm_cmd_e { - VMCS_SM_CMD_CLEAN_INVALID, - VMCS_SM_CMD_CLEAN_INVALID2, - -- VMCS_SM_CMD_LAST /* Do no delete */ -+ VMCS_SM_CMD_IMPORT_DMABUF, -+ -+ VMCS_SM_CMD_LAST /* Do not delete */ - }; - - /* Cache type supported, conveniently matches the user space definition in -@@ -188,6 +190,16 @@ struct vmcs_sm_ioctl_clean_invalid2 { - } s[0]; - }; - -+struct vmcs_sm_ioctl_import_dmabuf { -+ /* user -> kernel */ -+ int dmabuf_fd; -+ enum vmcs_sm_cache_e cached; -+ char name[VMCS_SM_RESOURCE_NAME]; -+ -+ /* kernel -> user */ -+ unsigned int handle; -+}; -+ - /* IOCTL numbers */ - #define VMCS_SM_IOCTL_MEM_ALLOC\ - _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_ALLOC,\ -@@ -257,6 +269,10 @@ struct vmcs_sm_ioctl_clean_invalid2 { - _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_HOST_WALK_PID_MAP,\ - struct vmcs_sm_ioctl_walk) - -+#define VMCS_SM_IOCTL_MEM_IMPORT_DMABUF\ -+ _IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_IMPORT_DMABUF,\ -+ struct vmcs_sm_ioctl_import_dmabuf) -+ - /* ---- Variable Externs ------------------------------------------------- */ - - /* ---- Function Prototypes ---------------------------------------------- */ - -From eb3b64dfcae6eb6adcbbd2c9f8292faa967cc129 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 16:26:12 +0100 -Subject: [PATCH 178/199] vcsm: Remove all typedefs from vc_sm_defs.h and - calling code - -Remove typedefs on the structures that make up the IPC -to the firmware for VCSM. Update all calling code appropriately. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_sm_defs.h | 83 ++++++++++++++++---------------- - drivers/char/broadcom/vc_sm/vc_sm_knl.h | 2 +- - drivers/char/broadcom/vc_sm/vc_vchi_sm.c | 34 +++++++------ - drivers/char/broadcom/vc_sm/vc_vchi_sm.h | 19 ++++---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 26 +++++----- - 5 files changed, 84 insertions(+), 80 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_defs.h b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -index bf057969644546d8f036044aa14d6606173b6a35..29057db43404716406b06e3c3745e3d82219be16 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_defs.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -@@ -19,14 +19,14 @@ - #define VC_SM_SERVER_NAME MAKE_FOURCC("SMEM") - - /* Maximum message length */ --#define VC_SM_MAX_MSG_LEN (sizeof(VC_SM_MSG_UNION_T) + \ -- sizeof(VC_SM_MSG_HDR_T)) --#define VC_SM_MAX_RSP_LEN (sizeof(VC_SM_MSG_UNION_T)) -+#define VC_SM_MAX_MSG_LEN (sizeof(union vc_sm_msg_union_t) + \ -+ sizeof(struct vc_sm_msg_hdr_t)) -+#define VC_SM_MAX_RSP_LEN (sizeof(union vc_sm_msg_union_t)) - - /* Resource name maximum size */ - #define VC_SM_RESOURCE_NAME 32 - --typedef enum { -+enum vc_sm_msg_type { - /* Message types supported for HOST->VC direction */ - - /* Allocate shared memory block */ -@@ -62,27 +62,26 @@ typedef enum { - VC_SM_MSG_TYPE_RELEASED, - - VC_SM_MSG_TYPE_MAX --} VC_SM_MSG_TYPE; -+}; - - /* Type of memory to be allocated */ --typedef enum { -+enum vc_sm_alloc_type_t { - VC_SM_ALLOC_CACHED, - VC_SM_ALLOC_NON_CACHED, -- --} VC_SM_ALLOC_TYPE_T; -+}; - - /* Message header for all messages in HOST->VC direction */ --typedef struct { -+struct vc_sm_msg_hdr_t { - int32_t type; - uint32_t trans_id; - uint8_t body[0]; - --} VC_SM_MSG_HDR_T; -+}; - - /* Request to allocate memory (HOST->VC) */ --typedef struct { -+struct vc_sm_alloc_t { - /* type of memory to allocate */ -- VC_SM_ALLOC_TYPE_T type; -+ enum vc_sm_alloc_type_t type; - /* byte amount of data to allocate per unit */ - uint32_t base_unit; - /* number of unit to allocate */ -@@ -94,10 +93,10 @@ typedef struct { - /* resource name (for easier tracking on vc side) */ - char name[VC_SM_RESOURCE_NAME]; - --} VC_SM_ALLOC_T; -+}; - - /* Result of a requested memory allocation (VC->HOST) */ --typedef struct { -+struct vc_sm_alloc_result_t { - /* Transaction identifier */ - uint32_t trans_id; - -@@ -110,28 +109,28 @@ typedef struct { - /* Resource number */ - uint32_t res_num; - --} VC_SM_ALLOC_RESULT_T; -+}; - - /* Request to free a previously allocated memory (HOST->VC) */ --typedef struct { -+struct vc_sm_free_t { - /* Resource handle (returned from alloc) */ - uint32_t res_handle; - /* Resource buffer (returned from alloc) */ - uint32_t res_mem; - --} VC_SM_FREE_T; -+}; - - /* Request to lock a previously allocated memory (HOST->VC) */ --typedef struct { -+struct vc_sm_lock_unlock_t { - /* Resource handle (returned from alloc) */ - uint32_t res_handle; - /* Resource buffer (returned from alloc) */ - uint32_t res_mem; - --} VC_SM_LOCK_UNLOCK_T; -+}; - - /* Request to resize a previously allocated memory (HOST->VC) */ --typedef struct { -+struct vc_sm_resize_t { - /* Resource handle (returned from alloc) */ - uint32_t res_handle; - /* Resource buffer (returned from alloc) */ -@@ -139,10 +138,10 @@ typedef struct { - /* Resource *new* size requested (bytes) */ - uint32_t res_new_size; - --} VC_SM_RESIZE_T; -+}; - - /* Result of a requested memory lock (VC->HOST) */ --typedef struct { -+struct vc_sm_lock_result_t { - /* Transaction identifier */ - uint32_t trans_id; - -@@ -154,37 +153,36 @@ typedef struct { - * was reallocated */ - uint32_t res_old_mem; - --} VC_SM_LOCK_RESULT_T; -+}; - - /* Generic result for a request (VC->HOST) */ --typedef struct { -+struct vc_sm_result_t { - /* Transaction identifier */ - uint32_t trans_id; - - int32_t success; - --} VC_SM_RESULT_T; -+}; - - /* Request to revert a previously applied action (HOST->VC) */ --typedef struct { -+struct vc_sm_action_clean_t { - /* Action of interest */ -- VC_SM_MSG_TYPE res_action; -+ enum vc_sm_msg_type res_action; - /* Transaction identifier for the action of interest */ - uint32_t action_trans_id; - --} VC_SM_ACTION_CLEAN_T; -+}; - - /* Request to remove all data associated with a given allocator (HOST->VC) */ --typedef struct { -+struct vc_sm_free_all_t { - /* Allocator identifier */ - uint32_t allocator; -- --} VC_SM_FREE_ALL_T; -+}; - - /* Request to import memory (HOST->VC) */ - struct vc_sm_import { - /* type of memory to allocate */ -- VC_SM_ALLOC_TYPE_T type; -+ enum vc_sm_alloc_type_t type; - /* pointer to the VC (ie physical) address of the allocated memory */ - uint32_t addr; - /* size of buffer */ -@@ -217,18 +215,19 @@ struct vc_sm_released { - }; - - /* Union of ALL messages */ --typedef union { -- VC_SM_ALLOC_T alloc; -- VC_SM_ALLOC_RESULT_T alloc_result; -- VC_SM_FREE_T free; -- VC_SM_ACTION_CLEAN_T action_clean; -- VC_SM_RESIZE_T resize; -- VC_SM_LOCK_RESULT_T lock_result; -- VC_SM_RESULT_T result; -- VC_SM_FREE_ALL_T free_all; -+union vc_sm_msg_union_t { -+ struct vc_sm_alloc_t alloc; -+ struct vc_sm_alloc_result_t alloc_result; -+ struct vc_sm_free_t free; -+ struct vc_sm_lock_unlock_t lock_unlock; -+ struct vc_sm_action_clean_t action_clean; -+ struct vc_sm_resize_t resize; -+ struct vc_sm_lock_result_t lock_result; -+ struct vc_sm_result_t result; -+ struct vc_sm_free_all_t free_all; - struct vc_sm_import import; - struct vc_sm_import_result import_result; - struct vc_sm_released released; --} VC_SM_MSG_UNION_T; -+}; - - #endif /* __VC_SM_DEFS_H__INCLUDED__ */ -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_knl.h b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -index 31050d3eb242b744c1ca43d6672d63b8439f7bc5..3c684ddde5c1fac5c726a71deec305f7588f0200 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_knl.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -@@ -27,7 +27,7 @@ typedef enum { - } VC_SM_LOCK_CACHE_MODE_T; - - /* Allocate a shared memory handle and block. */ --int vc_sm_alloc(VC_SM_ALLOC_T *alloc, int *handle); -+int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle); - - /* Free a previously allocated shared memory handle and block. */ - int vc_sm_free(int handle); -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -index 53fc11a9d5d741ec6a7e55b4d1934c9c43a6df8c..a702b0c16478c87e28be3905a14dcd992e6c05cb 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -@@ -83,11 +83,11 @@ bcm2835_vchi_msg_queue(VCHI_SERVICE_HANDLE_T handle, - - static struct - sm_cmd_rsp_blk *vc_vchi_cmd_create(struct sm_instance *instance, -- VC_SM_MSG_TYPE id, void *msg, -+ enum vc_sm_msg_type id, void *msg, - uint32_t size, int wait) - { - struct sm_cmd_rsp_blk *blk; -- VC_SM_MSG_HDR_T *hdr; -+ struct vc_sm_msg_hdr_t *hdr; - - if (down_interruptible(&instance->free_sema)) { - blk = kmalloc(sizeof(*blk), GFP_KERNEL); -@@ -109,7 +109,7 @@ sm_cmd_rsp_blk *vc_vchi_cmd_create(struct sm_instance *instance, - blk->wait = wait; - blk->length = sizeof(*hdr) + size; - -- hdr = (VC_SM_MSG_HDR_T *) blk->msg; -+ hdr = (struct vc_sm_msg_hdr_t *) blk->msg; - hdr->type = id; - mutex_lock(&instance->lock); - hdr->trans_id = blk->id = ++instance->trans_id; -@@ -139,7 +139,7 @@ static int vc_vchi_sm_videocore_io(void *arg) - { - struct sm_instance *instance = arg; - struct sm_cmd_rsp_blk *cmd = NULL, *cmd_tmp; -- VC_SM_RESULT_T *reply; -+ struct vc_sm_result_t *reply; - uint32_t reply_len; - int32_t status; - int svc_use = 1; -@@ -374,7 +374,7 @@ int vc_vchi_sm_stop(VC_VCHI_SM_HANDLE_T *handle) - } - - int vc_vchi_sm_send_msg(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_MSG_TYPE msg_id, -+ enum vc_sm_msg_type msg_id, - void *msg, uint32_t msg_size, - void *result, uint32_t result_size, - uint32_t *cur_trans_id, uint8_t wait_reply) -@@ -433,7 +433,8 @@ int vc_vchi_sm_send_msg(VC_VCHI_SM_HANDLE_T handle, - if (result && result_size) { - memcpy(result, cmd_blk->msg, result_size); - } else { -- VC_SM_RESULT_T *res = (VC_SM_RESULT_T *) cmd_blk->msg; -+ struct vc_sm_result_t *res = -+ (struct vc_sm_result_t *) cmd_blk->msg; - status = (res->success == 0) ? 0 : -ENXIO; - } - -@@ -444,8 +445,9 @@ int vc_vchi_sm_send_msg(VC_VCHI_SM_HANDLE_T handle, - return status; - } - --int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, VC_SM_ALLOC_T *msg, -- VC_SM_ALLOC_RESULT_T *result, uint32_t *cur_trans_id) -+int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_alloc_t *msg, -+ struct vc_sm_alloc_result_t *result, -+ uint32_t *cur_trans_id) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_ALLOC, - msg, sizeof(*msg), result, sizeof(*result), -@@ -453,15 +455,16 @@ int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, VC_SM_ALLOC_T *msg, - } - - int vc_vchi_sm_free(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_FREE_T *msg, uint32_t *cur_trans_id) -+ struct vc_sm_free_t *msg, uint32_t *cur_trans_id) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_FREE, - msg, sizeof(*msg), 0, 0, cur_trans_id, 0); - } - - int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_LOCK_UNLOCK_T *msg, -- VC_SM_LOCK_RESULT_T *result, uint32_t *cur_trans_id) -+ struct vc_sm_lock_unlock_t *msg, -+ struct vc_sm_lock_result_t *result, -+ uint32_t *cur_trans_id) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_LOCK, - msg, sizeof(*msg), result, sizeof(*result), -@@ -469,7 +472,7 @@ int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, - } - - int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_LOCK_UNLOCK_T *msg, -+ struct vc_sm_lock_unlock_t *msg, - uint32_t *cur_trans_id, uint8_t wait_reply) - { - return vc_vchi_sm_send_msg(handle, wait_reply ? -@@ -479,8 +482,8 @@ int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, - wait_reply); - } - --int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, VC_SM_RESIZE_T *msg, -- uint32_t *cur_trans_id) -+int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_resize_t *msg, -+ uint32_t *cur_trans_id) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_RESIZE, - msg, sizeof(*msg), 0, 0, cur_trans_id, 1); -@@ -492,7 +495,8 @@ int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle) - 0, 0, 0, 0, 0, 0); - } - --int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, VC_SM_ACTION_CLEAN_T *msg) -+int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, -+ struct vc_sm_action_clean_t *msg) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_ACTION_CLEAN, - msg, sizeof(*msg), 0, 0, 0, 0); -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -index 562217831fa744db99d94295c1c5a46f3a4780fb..f97cddf14881535c7f62a2ce0166a5eb7e3fad6d 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -@@ -41,31 +41,32 @@ int vc_vchi_sm_stop(VC_VCHI_SM_HANDLE_T *handle); - * return the result of this allocation (which upon success will be a pointer - * to some memory in videocore space). - */ --int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_ALLOC_T *alloc, -- VC_SM_ALLOC_RESULT_T *alloc_result, uint32_t *trans_id); -+int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_alloc_t *alloc, -+ struct vc_sm_alloc_result_t *alloc_result, -+ uint32_t *trans_id); - - /* - * Ask the shared memory service to free up some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. - */ - int vc_vchi_sm_free(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_FREE_T *free, uint32_t *trans_id); -+ struct vc_sm_free_t *free, uint32_t *trans_id); - - /* - * Ask the shared memory service to lock up some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. - */ - int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_LOCK_UNLOCK_T *lock_unlock, -- VC_SM_LOCK_RESULT_T *lock_result, uint32_t *trans_id); -+ struct vc_sm_lock_unlock_t *lock_unlock, -+ struct vc_sm_lock_result_t *lock_result, -+ uint32_t *trans_id); - - /* - * Ask the shared memory service to unlock some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. - */ - int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_LOCK_UNLOCK_T *lock_unlock, -+ struct vc_sm_lock_unlock_t *lock_unlock, - uint32_t *trans_id, uint8_t wait_reply); - - /* -@@ -73,7 +74,7 @@ int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, - * allocated by the vc_vchi_sm_alloc function call. - */ - int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_RESIZE_T *resize, uint32_t *trans_id); -+ struct vc_sm_resize_t *resize, uint32_t *trans_id); - - /* - * Walk the allocated resources on the videocore side, the allocation will -@@ -87,7 +88,7 @@ int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle); - * in a bad state of some sort. - */ - int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, -- VC_SM_ACTION_CLEAN_T *action_clean); -+ struct vc_sm_action_clean_t *action_clean); - - /* - * Import a contiguous block of memory and wrap it in a GPU MEM_HANDLE_T. -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 520f343f3f4b828f3045fc4ff3fb0d8a68bb1f9d..e67d96d54ad82bd51393268c830a51169f62b097 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -170,7 +170,7 @@ struct SM_PRIV_DATA_T { - struct SM_PDE_T dir_res; /* Debug fs resource sub-tree. */ - - int restart_sys; /* Tracks restart on interrupt. */ -- VC_SM_MSG_TYPE int_action; /* Interrupted action. */ -+ enum vc_sm_msg_type int_action; /* Interrupted action. */ - uint32_t int_trans_id; /* Interrupted transaction. */ - - }; -@@ -928,7 +928,7 @@ static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) - - /* Free up the videocore allocated resource. */ - if (resource->res_handle) { -- VC_SM_FREE_T free = { -+ struct vc_sm_free_t free = { - resource->res_handle, (uint32_t)resource->res_base_mem - }; - int status = vc_vchi_sm_free(sm_state->sm_handle, &free, -@@ -1123,7 +1123,7 @@ static int vc_sm_release(struct inode *inode, struct file *file) - pr_debug("[%s]: using private data %p\n", __func__, file_data); - - if (file_data->restart_sys == -EINTR) { -- VC_SM_ACTION_CLEAN_T action_clean; -+ struct vc_sm_action_clean_t action_clean; - - pr_debug("[%s]: releasing following EINTR on %u (trans_id: %u) (likely due to signal)...\n", - __func__, file_data->int_action, -@@ -1189,8 +1189,8 @@ static int vcsm_vma_fault(struct vm_fault *vmf) - /* Lock the resource if necessary. - */ - if (!resource->lock_count) { -- VC_SM_LOCK_UNLOCK_T lock_unlock; -- VC_SM_LOCK_RESULT_T lock_result; -+ struct vc_sm_lock_unlock_t lock_unlock; -+ struct vc_sm_lock_result_t lock_result; - int status; - - lock_unlock.res_handle = resource->res_handle; -@@ -1465,8 +1465,8 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - int ret = 0; - int status; - struct SM_RESOURCE_T *resource; -- VC_SM_ALLOC_T alloc = { 0 }; -- VC_SM_ALLOC_RESULT_T result = { 0 }; -+ struct vc_sm_alloc_t alloc = { 0 }; -+ struct vc_sm_alloc_result_t result = { 0 }; - enum vmcs_sm_cache_e cached = ioparam->cached; - bool map = false; - -@@ -1671,7 +1671,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - { - int ret = 0; - int status; -- VC_SM_RESIZE_T resize; -+ struct vc_sm_resize_t resize; - struct SM_RESOURCE_T *resource; - - /* Locate resource from GUID. -@@ -1761,8 +1761,8 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - unsigned int vc_addr) - { - int status; -- VC_SM_LOCK_UNLOCK_T lock; -- VC_SM_LOCK_RESULT_T result; -+ struct vc_sm_lock_unlock_t lock; -+ struct vc_sm_lock_result_t result; - struct SM_RESOURCE_T *resource; - int ret = 0; - struct sm_mmap *map, *map_tmp; -@@ -1935,7 +1935,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - int flush, int wait_reply, int no_vc_unlock) - { - int status; -- VC_SM_LOCK_UNLOCK_T unlock; -+ struct vc_sm_lock_unlock_t unlock; - struct sm_mmap *map, *map_tmp; - struct SM_RESOURCE_T *resource; - int ret = 0; -@@ -2261,7 +2261,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - - /* Action is a re-post of a previously interrupted action? */ - if (file_data->restart_sys == -EINTR) { -- VC_SM_ACTION_CLEAN_T action_clean; -+ struct vc_sm_action_clean_t action_clean; - - pr_debug("[%s]: clean up of action %u (trans_id: %u) following EINTR\n", - __func__, file_data->int_action, -@@ -3359,7 +3359,7 @@ static int bcm2835_vcsm_remove(struct platform_device *pdev) - - #if defined(__KERNEL__) - /* Allocate a shared memory handle and block. */ --int vc_sm_alloc(VC_SM_ALLOC_T *alloc, int *handle) -+int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle) - { - struct vmcs_sm_ioctl_alloc ioparam = { 0 }; - int ret; - -From e590f31b520dd4cac2556c30ae4f7cce04415894 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 16:29:53 +0100 -Subject: [PATCH 179/199] vcsm: Correct block comment style on licence headers. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_sm_defs.h | 28 +++++++++++++++------------- - drivers/char/broadcom/vc_sm/vc_sm_knl.h | 28 +++++++++++++++------------- - drivers/char/broadcom/vc_sm/vc_vchi_sm.c | 28 +++++++++++++++------------- - drivers/char/broadcom/vc_sm/vc_vchi_sm.h | 28 +++++++++++++++------------- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 28 +++++++++++++++------------- - 5 files changed, 75 insertions(+), 65 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_defs.h b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -index 29057db43404716406b06e3c3745e3d82219be16..8242e8ef28e445ae132187d02c74448b0226c1a4 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_defs.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -@@ -1,16 +1,18 @@ --/***************************************************************************** --* Copyright 2011 Broadcom Corporation. All rights reserved. --* --* Unless you and Broadcom execute a separate written software license --* agreement governing use of this software, this software is licensed to you --* under the terms of the GNU General Public License version 2, available at --* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). --* --* Notwithstanding the above, under no circumstances may you combine this --* software in any way with any other Broadcom software provided under a --* license other than the GPL, without Broadcom's express prior written --* consent. --*****************************************************************************/ -+/* -+ **************************************************************************** -+ * Copyright 2011 Broadcom Corporation. All rights reserved. -+ * -+ * Unless you and Broadcom execute a separate written software license -+ * agreement governing use of this software, this software is licensed to you -+ * under the terms of the GNU General Public License version 2, available at -+ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+ * -+ * Notwithstanding the above, under no circumstances may you combine this -+ * software in any way with any other Broadcom software provided under a -+ * license other than the GPL, without Broadcom's express prior written -+ * consent. -+ **************************************************************************** -+ */ - - #ifndef __VC_SM_DEFS_H__INCLUDED__ - #define __VC_SM_DEFS_H__INCLUDED__ -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_knl.h b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -index 3c684ddde5c1fac5c726a71deec305f7588f0200..8252d13999a78609fcc7e1bbe83307e2b1c1f8f1 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_knl.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -@@ -1,16 +1,18 @@ --/***************************************************************************** --* Copyright 2011 Broadcom Corporation. All rights reserved. --* --* Unless you and Broadcom execute a separate written software license --* agreement governing use of this software, this software is licensed to you --* under the terms of the GNU General Public License version 2, available at --* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). --* --* Notwithstanding the above, under no circumstances may you combine this --* software in any way with any other Broadcom software provided under a --* license other than the GPL, without Broadcom's express prior written --* consent. --*****************************************************************************/ -+/* -+ **************************************************************************** -+ * Copyright 2011 Broadcom Corporation. All rights reserved. -+ * -+ * Unless you and Broadcom execute a separate written software license -+ * agreement governing use of this software, this software is licensed to you -+ * under the terms of the GNU General Public License version 2, available at -+ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+ * -+ * Notwithstanding the above, under no circumstances may you combine this -+ * software in any way with any other Broadcom software provided under a -+ * license other than the GPL, without Broadcom's express prior written -+ * consent. -+ **************************************************************************** -+ */ - - #ifndef __VC_SM_KNL_H__INCLUDED__ - #define __VC_SM_KNL_H__INCLUDED__ -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -index a702b0c16478c87e28be3905a14dcd992e6c05cb..76678b2f84eb541aa816531f222b5b10f4e25382 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -@@ -1,16 +1,18 @@ --/***************************************************************************** --* Copyright 2011-2012 Broadcom Corporation. All rights reserved. --* --* Unless you and Broadcom execute a separate written software license --* agreement governing use of this software, this software is licensed to you --* under the terms of the GNU General Public License version 2, available at --* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). --* --* Notwithstanding the above, under no circumstances may you combine this --* software in any way with any other Broadcom software provided under a --* license other than the GPL, without Broadcom's express prior written --* consent. --*****************************************************************************/ -+/* -+ **************************************************************************** -+ * Copyright 2011-2012 Broadcom Corporation. All rights reserved. -+ * -+ * Unless you and Broadcom execute a separate written software license -+ * agreement governing use of this software, this software is licensed to you -+ * under the terms of the GNU General Public License version 2, available at -+ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+ * -+ * Notwithstanding the above, under no circumstances may you combine this -+ * software in any way with any other Broadcom software provided under a -+ * license other than the GPL, without Broadcom's express prior written -+ * consent. -+ **************************************************************************** -+ */ - - /* ---- Include Files ----------------------------------------------------- */ - #include -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -index f97cddf14881535c7f62a2ce0166a5eb7e3fad6d..110db20ef517af9589616e5892c5b48681e62966 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -@@ -1,16 +1,18 @@ --/***************************************************************************** --* Copyright 2011 Broadcom Corporation. All rights reserved. --* --* Unless you and Broadcom execute a separate written software license --* agreement governing use of this software, this software is licensed to you --* under the terms of the GNU General Public License version 2, available at --* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). --* --* Notwithstanding the above, under no circumstances may you combine this --* software in any way with any other Broadcom software provided under a --* license other than the GPL, without Broadcom's express prior written --* consent. --*****************************************************************************/ -+/* -+ **************************************************************************** -+ * Copyright 2011 Broadcom Corporation. All rights reserved. -+ * -+ * Unless you and Broadcom execute a separate written software license -+ * agreement governing use of this software, this software is licensed to you -+ * under the terms of the GNU General Public License version 2, available at -+ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+ * -+ * Notwithstanding the above, under no circumstances may you combine this -+ * software in any way with any other Broadcom software provided under a -+ * license other than the GPL, without Broadcom's express prior written -+ * consent. -+ **************************************************************************** -+ */ - - #ifndef __VC_VCHI_SM_H__INCLUDED__ - #define __VC_VCHI_SM_H__INCLUDED__ -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index e67d96d54ad82bd51393268c830a51169f62b097..b121de3c2502e3d7fb6ef1c1b5e4d797d1f5d233 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -1,16 +1,18 @@ --/***************************************************************************** --* Copyright 2011-2012 Broadcom Corporation. All rights reserved. --* --* Unless you and Broadcom execute a separate written software license --* agreement governing use of this software, this software is licensed to you --* under the terms of the GNU General Public License version 2, available at --* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). --* --* Notwithstanding the above, under no circumstances may you combine this --* software in any way with any other Broadcom software provided under a --* license other than the GPL, without Broadcom's express prior written --* consent. --*****************************************************************************/ -+/* -+ **************************************************************************** -+ * Copyright 2011-2012 Broadcom Corporation. All rights reserved. -+ * -+ * Unless you and Broadcom execute a separate written software license -+ * agreement governing use of this software, this software is licensed to you -+ * under the terms of the GNU General Public License version 2, available at -+ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). -+ * -+ * Notwithstanding the above, under no circumstances may you combine this -+ * software in any way with any other Broadcom software provided under a -+ * license other than the GPL, without Broadcom's express prior written -+ * consent. -+ **************************************************************************** -+ */ - - /* ---- Include Files ----------------------------------------------------- */ - - -From 8319293c88f09bc266aee8e0451a5e7934587903 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 16:34:13 +0100 -Subject: [PATCH 180/199] vcsm: Fix block comment formatting - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_sm_defs.h | 6 ++++-- - drivers/char/broadcom/vc_sm/vc_vchi_sm.h | 10 +++++----- - 2 files changed, 9 insertions(+), 7 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_defs.h b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -index 8242e8ef28e445ae132187d02c74448b0226c1a4..de6afe9f65af45582c79a62abd41c688274ad8f2 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_defs.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_defs.h -@@ -151,8 +151,10 @@ struct vc_sm_lock_result_t { - uint32_t res_handle; - /* Pointer to resource buffer */ - uint32_t res_mem; -- /* Pointer to former resource buffer if the memory -- * was reallocated */ -+ /* -+ * Pointer to former resource buffer if the memory -+ * was reallocated -+ */ - uint32_t res_old_mem; - - }; -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -index 110db20ef517af9589616e5892c5b48681e62966..48e721c7f2e4ac5abe376a8481e01b0bbcc6d3ad 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -@@ -23,7 +23,7 @@ - - /* - * Forward declare. --*/ -+ */ - typedef struct sm_instance *VC_VCHI_SM_HANDLE_T; - - /* -@@ -57,7 +57,7 @@ int vc_vchi_sm_free(VC_VCHI_SM_HANDLE_T handle, - /* - * Ask the shared memory service to lock up some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. --*/ -+ */ - int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, - struct vc_sm_lock_unlock_t *lock_unlock, - struct vc_sm_lock_result_t *lock_result, -@@ -66,7 +66,7 @@ int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, - /* - * Ask the shared memory service to unlock some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. --*/ -+ */ - int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, - struct vc_sm_lock_unlock_t *lock_unlock, - uint32_t *trans_id, uint8_t wait_reply); -@@ -74,7 +74,7 @@ int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, - /* - * Ask the shared memory service to resize some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. --*/ -+ */ - int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, - struct vc_sm_resize_t *resize, uint32_t *trans_id); - -@@ -82,7 +82,7 @@ int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, - * Walk the allocated resources on the videocore side, the allocation will - * show up in the log. This is purely for debug/information and takes no - * specific actions. --*/ -+ */ - int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle); - - /* - -From e5473bf342fcd4a4e3b3fd80c057d21a41f84c98 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 16:50:29 +0100 -Subject: [PATCH 181/199] vcsm: Remove typedef of VC_VCHI_SM_HANDLE_T - -Replaced with struct sm_instance *. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_vchi_sm.c | 22 +++++++++++----------- - drivers/char/broadcom/vc_sm/vc_vchi_sm.h | 22 +++++++++++----------- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 2 +- - 3 files changed, 23 insertions(+), 23 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -index 76678b2f84eb541aa816531f222b5b10f4e25382..cc1752e9d42ebd1785cbe7dc0607b7e9c03f49de 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -@@ -257,7 +257,7 @@ static void vc_sm_vchi_callback(void *param, - } - } - --VC_VCHI_SM_HANDLE_T vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, -+struct sm_instance *vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, - VCHI_CONNECTION_T **vchi_connections, - uint32_t num_connections) - { -@@ -341,7 +341,7 @@ VC_VCHI_SM_HANDLE_T vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, - return NULL; - } - --int vc_vchi_sm_stop(VC_VCHI_SM_HANDLE_T *handle) -+int vc_vchi_sm_stop(struct sm_instance **handle) - { - struct sm_instance *instance; - uint32_t i; -@@ -375,7 +375,7 @@ int vc_vchi_sm_stop(VC_VCHI_SM_HANDLE_T *handle) - return -EINVAL; - } - --int vc_vchi_sm_send_msg(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_send_msg(struct sm_instance *handle, - enum vc_sm_msg_type msg_id, - void *msg, uint32_t msg_size, - void *result, uint32_t result_size, -@@ -447,7 +447,7 @@ int vc_vchi_sm_send_msg(VC_VCHI_SM_HANDLE_T handle, - return status; - } - --int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_alloc_t *msg, -+int vc_vchi_sm_alloc(struct sm_instance *handle, struct vc_sm_alloc_t *msg, - struct vc_sm_alloc_result_t *result, - uint32_t *cur_trans_id) - { -@@ -456,14 +456,14 @@ int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_alloc_t *msg, - cur_trans_id, 1); - } - --int vc_vchi_sm_free(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_free(struct sm_instance *handle, - struct vc_sm_free_t *msg, uint32_t *cur_trans_id) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_FREE, - msg, sizeof(*msg), 0, 0, cur_trans_id, 0); - } - --int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_lock(struct sm_instance *handle, - struct vc_sm_lock_unlock_t *msg, - struct vc_sm_lock_result_t *result, - uint32_t *cur_trans_id) -@@ -473,7 +473,7 @@ int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, - cur_trans_id, 1); - } - --int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_unlock(struct sm_instance *handle, - struct vc_sm_lock_unlock_t *msg, - uint32_t *cur_trans_id, uint8_t wait_reply) - { -@@ -484,27 +484,27 @@ int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, - wait_reply); - } - --int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_resize_t *msg, -+int vc_vchi_sm_resize(struct sm_instance *handle, struct vc_sm_resize_t *msg, - uint32_t *cur_trans_id) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_RESIZE, - msg, sizeof(*msg), 0, 0, cur_trans_id, 1); - } - --int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle) -+int vc_vchi_sm_walk_alloc(struct sm_instance *handle) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_WALK_ALLOC, - 0, 0, 0, 0, 0, 0); - } - --int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_clean_up(struct sm_instance *handle, - struct vc_sm_action_clean_t *msg) - { - return vc_vchi_sm_send_msg(handle, VC_SM_MSG_TYPE_ACTION_CLEAN, - msg, sizeof(*msg), 0, 0, 0, 0); - } - --int vc_vchi_sm_import(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_import *msg, -+int vc_vchi_sm_import(struct sm_instance *handle, struct vc_sm_import *msg, - struct vc_sm_import_result *result, - uint32_t *cur_trans_id) - { -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -index 48e721c7f2e4ac5abe376a8481e01b0bbcc6d3ad..abe4ed15836f2be756083d3fdb4edb544dacc1a6 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.h -@@ -24,26 +24,26 @@ - /* - * Forward declare. - */ --typedef struct sm_instance *VC_VCHI_SM_HANDLE_T; -+struct sm_instance; - - /* - * Initialize the shared memory service, opens up vchi connection to talk to it. - */ --VC_VCHI_SM_HANDLE_T vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, -+struct sm_instance *vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, - VCHI_CONNECTION_T **vchi_connections, - uint32_t num_connections); - - /* - * Terminates the shared memory service. - */ --int vc_vchi_sm_stop(VC_VCHI_SM_HANDLE_T *handle); -+int vc_vchi_sm_stop(struct sm_instance **handle); - - /* - * Ask the shared memory service to allocate some memory on videocre and - * return the result of this allocation (which upon success will be a pointer - * to some memory in videocore space). - */ --int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_alloc_t *alloc, -+int vc_vchi_sm_alloc(struct sm_instance *handle, struct vc_sm_alloc_t *alloc, - struct vc_sm_alloc_result_t *alloc_result, - uint32_t *trans_id); - -@@ -51,14 +51,14 @@ int vc_vchi_sm_alloc(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_alloc_t *alloc, - * Ask the shared memory service to free up some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. - */ --int vc_vchi_sm_free(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_free(struct sm_instance *handle, - struct vc_sm_free_t *free, uint32_t *trans_id); - - /* - * Ask the shared memory service to lock up some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. - */ --int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_lock(struct sm_instance *handle, - struct vc_sm_lock_unlock_t *lock_unlock, - struct vc_sm_lock_result_t *lock_result, - uint32_t *trans_id); -@@ -67,7 +67,7 @@ int vc_vchi_sm_lock(VC_VCHI_SM_HANDLE_T handle, - * Ask the shared memory service to unlock some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. - */ --int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_unlock(struct sm_instance *handle, - struct vc_sm_lock_unlock_t *lock_unlock, - uint32_t *trans_id, uint8_t wait_reply); - -@@ -75,7 +75,7 @@ int vc_vchi_sm_unlock(VC_VCHI_SM_HANDLE_T handle, - * Ask the shared memory service to resize some memory that was previously - * allocated by the vc_vchi_sm_alloc function call. - */ --int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_resize(struct sm_instance *handle, - struct vc_sm_resize_t *resize, uint32_t *trans_id); - - /* -@@ -83,19 +83,19 @@ int vc_vchi_sm_resize(VC_VCHI_SM_HANDLE_T handle, - * show up in the log. This is purely for debug/information and takes no - * specific actions. - */ --int vc_vchi_sm_walk_alloc(VC_VCHI_SM_HANDLE_T handle); -+int vc_vchi_sm_walk_alloc(struct sm_instance *handle); - - /* - * Clean up following a previously interrupted action which left the system - * in a bad state of some sort. - */ --int vc_vchi_sm_clean_up(VC_VCHI_SM_HANDLE_T handle, -+int vc_vchi_sm_clean_up(struct sm_instance *handle, - struct vc_sm_action_clean_t *action_clean); - - /* - * Import a contiguous block of memory and wrap it in a GPU MEM_HANDLE_T. - */ --int vc_vchi_sm_import(VC_VCHI_SM_HANDLE_T handle, struct vc_sm_import *msg, -+int vc_vchi_sm_import(struct sm_instance *handle, struct vc_sm_import *msg, - struct vc_sm_import_result *result, - uint32_t *cur_trans_id); - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index b121de3c2502e3d7fb6ef1c1b5e4d797d1f5d233..8c13dab0f59c959226194214d36d9b5c8c6b1818 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -181,7 +181,7 @@ struct SM_PRIV_DATA_T { - */ - struct SM_STATE_T { - struct platform_device *pdev; -- VC_VCHI_SM_HANDLE_T sm_handle; /* Handle for videocore service. */ -+ struct sm_instance *sm_handle; /* Handle for videocore service. */ - struct dentry *dir_root; /* Debug fs entries root. */ - struct dentry *dir_alloc; /* Debug fs entries allocations. */ - struct SM_PDE_T dir_stats; /* Debug fs entries statistics sub-tree. */ - -From 4ca3276fb4a30f6c1f44d41faa1769cef1e3c90c Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 16:55:08 +0100 -Subject: [PATCH 182/199] vcsm: "unsigned int" preferred over "unsigned" fixed. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_vchi_sm.c | 3 ++- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 2 +- - 2 files changed, 3 insertions(+), 2 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -index cc1752e9d42ebd1785cbe7dc0607b7e9c03f49de..b9f65e34957506ba0f93d0d0ecd0894ee5be39b5 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -@@ -327,7 +327,8 @@ struct sm_instance *vc_vchi_sm_init(VCHI_INSTANCE_T vchi_instance, - set_user_nice(instance->io_thread, -10); - wake_up_process(instance->io_thread); - -- pr_debug("%s: success - instance 0x%x", __func__, (unsigned)instance); -+ pr_debug("%s: success - instance 0x%x", __func__, -+ (unsigned int)instance); - return instance; - - err_close_services: -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 8c13dab0f59c959226194214d36d9b5c8c6b1818..8bea643957622cb19b9daac124447fe90558e47c 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -227,7 +227,7 @@ static const char *const sm_cache_map_vector[] = { - - /* ---- Private Functions ------------------------------------------------ */ - --static inline unsigned vcaddr_to_pfn(unsigned long vc_addr) -+static inline unsigned int vcaddr_to_pfn(unsigned long vc_addr) - { - unsigned long pfn = vc_addr & 0x3FFFFFFF; - pfn += mm_vc_mem_phys_addr; - -From 2d10ce1a39ed212bf01e9431578d970874607bdb Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 16:59:49 +0100 -Subject: [PATCH 183/199] vcsm: Fix blank lines after declarations. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_vchi_sm.c | 1 + - drivers/char/broadcom/vc_sm/vmcs_sm.c | 7 +++++++ - 2 files changed, 8 insertions(+) - -diff --git a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -index b9f65e34957506ba0f93d0d0ecd0894ee5be39b5..f8b909a09adb0743ed5d55dadf8fbf2fef055197 100644 ---- a/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -+++ b/drivers/char/broadcom/vc_sm/vc_vchi_sm.c -@@ -362,6 +362,7 @@ int vc_vchi_sm_stop(struct sm_instance **handle) - /* Close all VCHI service connections */ - for (i = 0; i < instance->num_connections; i++) { - int32_t success; -+ - vchi_service_use(instance->vchi_handle[i]); - - success = vchi_service_close(instance->vchi_handle[i]); -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 8bea643957622cb19b9daac124447fe90558e47c..abee526d6fbbddb8c31096cafdcd69814590d750 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -230,6 +230,7 @@ static const char *const sm_cache_map_vector[] = { - static inline unsigned int vcaddr_to_pfn(unsigned long vc_addr) - { - unsigned long pfn = vc_addr & 0x3FFFFFFF; -+ - pfn += mm_vc_mem_phys_addr; - pfn >>= PAGE_SHIFT; - return pfn; -@@ -1441,9 +1442,11 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - if (resource->map) { - /* We don't use vmf->pgoff since that has the fake offset */ - unsigned long addr; -+ - for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) { - /* Finally, remap it */ - unsigned long pfn = (unsigned long)resource->res_base_mem & 0x3FFFFFFF; -+ - pfn += mm_vc_mem_phys_addr; - pfn += addr - vma->vm_start; - pfn >>= PAGE_SHIFT; -@@ -1974,6 +1977,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - /* Flush if requested */ - if (resource->res_cached && flush) { - dma_addr_t phys_addr = 0; -+ - resource->res_stats[FLUSH]++; - - phys_addr = -@@ -1988,6 +1992,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - if (map->vma) { - unsigned long start; - unsigned long end; -+ - start = map->vma->vm_start; - end = map->vma->vm_end; - -@@ -3022,6 +3027,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - if ((resource != NULL) && resource->res_cached) { - unsigned long base = ioparam.s[i].addr & ~(PAGE_SIZE-1); - unsigned long end = (ioparam.s[i].addr + ioparam.s[i].size + PAGE_SIZE-1) & ~(PAGE_SIZE-1); -+ - resource->res_stats[ioparam.s[i].cmd == 1 ? INVALID:FLUSH]++; - - /* L1/L2 cache flush */ -@@ -3071,6 +3077,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - - for (i=0; iblock_count; ++j) { - - - -From be8605f2967a6a59ae6b32a9381717240980616a Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:01:11 +0100 -Subject: [PATCH 184/199] vcsm: Fix erroneous space in 'if' statement. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index abee526d6fbbddb8c31096cafdcd69814590d750..6d4729980ebf7dd7b76444dcabf3c85477b51fd4 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -1476,7 +1476,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - bool map = false; - - /* flag to requst buffer is mapped up front, rather than lazily */ -- if (cached & 0x80 ) { -+ if (cached & 0x80) { - map = true; - cached &= ~0x80; - } - -From 520fa3d662564695842f90684b77e5de587e90b8 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:21:09 +0100 -Subject: [PATCH 185/199] vcsm: Fix lots of block quote formatting issues - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 563 ++++++++++++++-------------------- - 1 file changed, 231 insertions(+), 332 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 6d4729980ebf7dd7b76444dcabf3c85477b51fd4..f93f18d3c24e43c9cf79e33f11cba9d1806f3124 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -61,8 +61,7 @@ - #define VC_SM_DEBUG "debug" - #define VC_SM_WRITE_BUF_SIZE 128 - --/* Statistics tracked per resource and globally. --*/ -+/* Statistics tracked per resource and globally. */ - enum SM_STATS_T { - /* Attempt. */ - ALLOC, -@@ -109,27 +108,25 @@ struct SM_PDE_T { - - }; - --/* Single resource allocation tracked for all devices. --*/ -+/* Single resource allocation tracked for all devices. */ - struct sm_mmap { - struct list_head map_list; /* Linked list of maps. */ - - struct SM_RESOURCE_T *resource; /* Pointer to the resource. */ - -- pid_t res_pid; /* PID owning that resource. */ -+ pid_t res_pid; /* PID owning that resource. */ - unsigned int res_vc_hdl; /* Resource handle (videocore). */ - unsigned int res_usr_hdl; /* Resource handle (user). */ - - long unsigned int res_addr; /* Mapped virtual address. */ - struct vm_area_struct *vma; /* VM area for this mapping. */ -- unsigned int ref_count; /* Reference count to this vma. */ -+ unsigned int ref_count; /* Reference count to this vma. */ - - /* Used to link maps associated with a resource. */ - struct list_head resource_map_list; - }; - --/* Single resource allocation tracked for each opened device. --*/ -+/* Single resource allocation tracked for each opened device. */ - struct SM_RESOURCE_T { - struct list_head resource_list; /* List of resources. */ - struct list_head global_resource_list; /* Global list of resources. */ -@@ -160,8 +157,7 @@ struct SM_RESOURCE_T { - bool map; /* whether to map pages up front */ - }; - --/* Private file data associated with each opened device. --*/ -+/* Private file data associated with each opened device. */ - struct SM_PRIV_DATA_T { - struct list_head resource_list; /* List of resources. */ - -@@ -177,8 +173,7 @@ struct SM_PRIV_DATA_T { - - }; - --/* Global state information. --*/ -+/* Global state information. */ - struct SM_STATE_T { - struct platform_device *pdev; - struct sm_instance *sm_handle; /* Handle for videocore service. */ -@@ -236,9 +231,10 @@ static inline unsigned int vcaddr_to_pfn(unsigned long vc_addr) - return pfn; - } - --/* Carries over to the state statistics the statistics once owned by a deceased --** resource. --*/ -+/* -+ * Carries over to the state statistics the statistics once owned by a deceased -+ * resource. -+ */ - static void vc_sm_resource_deceased(struct SM_RESOURCE_T *p_res, int terminated) - { - if (sm_state != NULL) { -@@ -262,9 +258,10 @@ static void vc_sm_resource_deceased(struct SM_RESOURCE_T *p_res, int terminated) - } - } - --/* Fetch a videocore handle corresponding to a mapping of the pid+address --** returns 0 (ie NULL) if no such handle exists in the global map. --*/ -+/* -+ * Fetch a videocore handle corresponding to a mapping of the pid+address -+ * returns 0 (ie NULL) if no such handle exists in the global map. -+ */ - static unsigned int vmcs_sm_vc_handle_from_pid_and_address(unsigned int pid, - unsigned int addr) - { -@@ -276,8 +273,7 @@ static unsigned int vmcs_sm_vc_handle_from_pid_and_address(unsigned int pid, - - mutex_lock(&(sm_state->map_lock)); - -- /* Lookup the resource. -- */ -+ /* Lookup the resource. */ - if (!list_empty(&sm_state->map_list)) { - list_for_each_entry(map, &sm_state->map_list, map_list) { - if (map->res_pid != pid || map->res_addr != addr) -@@ -295,13 +291,14 @@ static unsigned int vmcs_sm_vc_handle_from_pid_and_address(unsigned int pid, - mutex_unlock(&(sm_state->map_lock)); - - out: -- /* Use a debug log here as it may be a valid situation that we query -- ** for something that is not mapped, we do not want a kernel log each -- ** time around. -- ** -- ** There are other error log that would pop up accordingly if someone -- ** subsequently tries to use something invalid after being told not to -- ** use it... -+ /* -+ * Use a debug log here as it may be a valid situation that we query -+ * for something that is not mapped, we do not want a kernel log each -+ * time around. -+ * -+ * There are other error log that would pop up accordingly if someone -+ * subsequently tries to use something invalid after being told not to -+ * use it... - */ - if (handle == 0) { - pr_debug("[%s]: not a valid map (pid %u, addr %x)\n", -@@ -311,9 +308,10 @@ static unsigned int vmcs_sm_vc_handle_from_pid_and_address(unsigned int pid, - return handle; - } - --/* Fetch a user handle corresponding to a mapping of the pid+address --** returns 0 (ie NULL) if no such handle exists in the global map. --*/ -+/* -+ * Fetch a user handle corresponding to a mapping of the pid+address -+ * returns 0 (ie NULL) if no such handle exists in the global map. -+ */ - static unsigned int vmcs_sm_usr_handle_from_pid_and_address(unsigned int pid, - unsigned int addr) - { -@@ -325,8 +323,7 @@ static unsigned int vmcs_sm_usr_handle_from_pid_and_address(unsigned int pid, - - mutex_lock(&(sm_state->map_lock)); - -- /* Lookup the resource. -- */ -+ /* Lookup the resource. */ - if (!list_empty(&sm_state->map_list)) { - list_for_each_entry(map, &sm_state->map_list, map_list) { - if (map->res_pid != pid || map->res_addr != addr) -@@ -344,7 +341,8 @@ static unsigned int vmcs_sm_usr_handle_from_pid_and_address(unsigned int pid, - mutex_unlock(&(sm_state->map_lock)); - - out: -- /* Use a debug log here as it may be a valid situation that we query -+ /* -+ * Use a debug log here as it may be a valid situation that we query - * for something that is not mapped yet. - * - * There are other error log that would pop up accordingly if someone -@@ -359,9 +357,10 @@ static unsigned int vmcs_sm_usr_handle_from_pid_and_address(unsigned int pid, - } - - #if defined(DO_NOT_USE) --/* Fetch an address corresponding to a mapping of the pid+handle --** returns 0 (ie NULL) if no such address exists in the global map. --*/ -+/* -+ * Fetch an address corresponding to a mapping of the pid+handle -+ * returns 0 (ie NULL) if no such address exists in the global map. -+ */ - static unsigned int vmcs_sm_usr_address_from_pid_and_vc_handle(unsigned int pid, - unsigned int hdl) - { -@@ -373,8 +372,7 @@ static unsigned int vmcs_sm_usr_address_from_pid_and_vc_handle(unsigned int pid, - - mutex_lock(&(sm_state->map_lock)); - -- /* Lookup the resource. -- */ -+ /* Lookup the resource. */ - if (!list_empty(&sm_state->map_list)) { - list_for_each_entry(map, &sm_state->map_list, map_list) { - if (map->res_pid != pid || map->res_vc_hdl != hdl) -@@ -392,13 +390,14 @@ static unsigned int vmcs_sm_usr_address_from_pid_and_vc_handle(unsigned int pid, - mutex_unlock(&(sm_state->map_lock)); - - out: -- /* Use a debug log here as it may be a valid situation that we query -- ** for something that is not mapped, we do not want a kernel log each -- ** time around. -- ** -- ** There are other error log that would pop up accordingly if someone -- ** subsequently tries to use something invalid after being told not to -- ** use it... -+ /* -+ * Use a debug log here as it may be a valid situation that we query -+ * for something that is not mapped, we do not want a kernel log each -+ * time around. -+ * -+ * There are other error log that would pop up accordingly if someone -+ * subsequently tries to use something invalid after being told not to -+ * use it... - */ - if (addr == 0) - pr_debug("[%s]: not a valid map (pid %u, hdl %x)\n", -@@ -408,9 +407,10 @@ static unsigned int vmcs_sm_usr_address_from_pid_and_vc_handle(unsigned int pid, - } - #endif - --/* Fetch an address corresponding to a mapping of the pid+handle --** returns 0 (ie NULL) if no such address exists in the global map. --*/ -+/* -+ * Fetch an address corresponding to a mapping of the pid+handle -+ * returns 0 (ie NULL) if no such address exists in the global map. -+ */ - static unsigned int vmcs_sm_usr_address_from_pid_and_usr_handle(unsigned int - pid, - unsigned int -@@ -424,8 +424,7 @@ static unsigned int vmcs_sm_usr_address_from_pid_and_usr_handle(unsigned int - - mutex_lock(&(sm_state->map_lock)); - -- /* Lookup the resource. -- */ -+ /* Lookup the resource. */ - if (!list_empty(&sm_state->map_list)) { - list_for_each_entry(map, &sm_state->map_list, map_list) { - if (map->res_pid != pid || map->res_usr_hdl != hdl) -@@ -443,7 +442,8 @@ static unsigned int vmcs_sm_usr_address_from_pid_and_usr_handle(unsigned int - mutex_unlock(&(sm_state->map_lock)); - - out: -- /* Use a debug log here as it may be a valid situation that we query -+ /* -+ * Use a debug log here as it may be a valid situation that we query - * for something that is not mapped, we do not want a kernel log each - * time around. - * -@@ -458,19 +458,16 @@ static unsigned int vmcs_sm_usr_address_from_pid_and_usr_handle(unsigned int - return addr; - } - --/* Adds a resource mapping to the global data list. --*/ -+/* Adds a resource mapping to the global data list. */ - static void vmcs_sm_add_map(struct SM_STATE_T *state, - struct SM_RESOURCE_T *resource, struct sm_mmap *map) - { - mutex_lock(&(state->map_lock)); - -- /* Add to the global list of mappings -- */ -+ /* Add to the global list of mappings */ - list_add(&map->map_list, &state->map_list); - -- /* Add to the list of mappings for this resource -- */ -+ /* Add to the list of mappings for this resource */ - list_add(&map->resource_map_list, &resource->map_list); - resource->map_count++; - -@@ -481,20 +478,17 @@ static void vmcs_sm_add_map(struct SM_STATE_T *state, - map->res_usr_hdl, map->res_addr); - } - --/* Removes a resource mapping from the global data list. --*/ -+/* Removes a resource mapping from the global data list. */ - static void vmcs_sm_remove_map(struct SM_STATE_T *state, - struct SM_RESOURCE_T *resource, - struct sm_mmap *map) - { - mutex_lock(&(state->map_lock)); - -- /* Remove from the global list of mappings -- */ -+ /* Remove from the global list of mappings */ - list_del(&map->map_list); - -- /* Remove from the list of mapping for this resource -- */ -+ /* Remove from the list of mapping for this resource */ - list_del(&map->resource_map_list); - if (resource->map_count > 0) - resource->map_count--; -@@ -508,8 +502,7 @@ static void vmcs_sm_remove_map(struct SM_STATE_T *state, - kfree(map); - } - --/* Read callback for the global state proc entry. --*/ -+/* Read callback for the global state proc entry. */ - static int vc_sm_global_state_show(struct seq_file *s, void *v) - { - struct sm_mmap *map = NULL; -@@ -523,8 +516,7 @@ static int vc_sm_global_state_show(struct seq_file *s, void *v) - seq_printf(s, "\nVC-ServiceHandle 0x%x\n", - (unsigned int)sm_state->sm_handle); - -- /* Log all applicable mapping(s). -- */ -+ /* Log all applicable mapping(s). */ - - mutex_lock(&(sm_state->map_lock)); - seq_puts(s, "\nResources\n"); -@@ -591,8 +583,7 @@ static int vc_sm_global_statistics_show(struct seq_file *s, void *v) - { - int ix; - -- /* Global state tracked statistics. -- */ -+ /* Global state tracked statistics. */ - if (sm_state != NULL) { - seq_puts(s, "\nDeceased Resources Statistics\n"); - -@@ -638,8 +629,7 @@ static int vc_sm_global_statistics_show(struct seq_file *s, void *v) - } - - #if 0 --/* Read callback for the statistics proc entry. --*/ -+/* Read callback for the statistics proc entry. */ - static int vc_sm_statistics_show(struct seq_file *s, void *v) - { - int ix; -@@ -654,8 +644,7 @@ static int vc_sm_statistics_show(struct seq_file *s, void *v) - if (file_data == NULL) - return 0; - -- /* Per process statistics. -- */ -+ /* Per process statistics. */ - - seq_printf(s, "\nStatistics for TGID %d\n", file_data->pid); - -@@ -771,9 +760,10 @@ static const struct file_operations vc_sm_debug_fs_fops = { - .release = single_release, - }; - --/* Adds a resource to the private data list which tracks all the allocated --** data. --*/ -+/* -+ * Adds a resource to the private data list which tracks all the allocated -+ * data. -+ */ - static void vmcs_sm_add_resource(struct SM_PRIV_DATA_T *privdata, - struct SM_RESOURCE_T *resource) - { -@@ -787,9 +777,10 @@ static void vmcs_sm_add_resource(struct SM_PRIV_DATA_T *privdata, - resource->res_handle, resource->res_size, resource->res_cached); - } - --/* Locates a resource and acquire a reference on it. --** The resource won't be deleted while there is a reference on it. --*/ -+/* -+ * Locates a resource and acquire a reference on it. -+ * The resource won't be deleted while there is a reference on it. -+ */ - static struct SM_RESOURCE_T *vmcs_sm_acquire_resource(struct SM_PRIV_DATA_T - *private, - unsigned int res_guid) -@@ -816,9 +807,10 @@ static struct SM_RESOURCE_T *vmcs_sm_acquire_resource(struct SM_PRIV_DATA_T - return ret; - } - --/* Locates a resource and acquire a reference on it. --** The resource won't be deleted while there is a reference on it. --*/ -+/* -+ * Locates a resource and acquire a reference on it. -+ * The resource won't be deleted while there is a reference on it. -+ */ - static struct SM_RESOURCE_T *vmcs_sm_acquire_first_resource( - struct SM_PRIV_DATA_T *private) - { -@@ -841,9 +833,10 @@ static struct SM_RESOURCE_T *vmcs_sm_acquire_first_resource( - return ret; - } - --/* Locates a resource and acquire a reference on it. --** The resource won't be deleted while there is a reference on it. --*/ -+/* -+ * Locates a resource and acquire a reference on it. -+ * The resource won't be deleted while there is a reference on it. -+ */ - static struct SM_RESOURCE_T *vmcs_sm_acquire_global_resource(unsigned int - res_guid) - { -@@ -870,9 +863,10 @@ static struct SM_RESOURCE_T *vmcs_sm_acquire_global_resource(unsigned int - return ret; - } - --/* Release a previously acquired resource. --** The resource will be deleted when its refcount reaches 0. --*/ -+/* -+ * Release a previously acquired resource. -+ * The resource will be deleted when its refcount reaches 0. -+ */ - static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) - { - struct SM_PRIV_DATA_T *private = resource->private; -@@ -961,16 +955,16 @@ static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) - kfree(resource); - } - --/* Dump the map table for the driver. If process is -1, dumps the whole table, --** if process is a valid pid (non -1) dump only the entries associated with the --** pid of interest. --*/ -+/* -+ * Dump the map table for the driver. If process is -1, dumps the whole table, -+ * if process is a valid pid (non -1) dump only the entries associated with the -+ * pid of interest. -+ */ - static void vmcs_sm_host_walk_map_per_pid(int pid) - { - struct sm_mmap *map = NULL; - -- /* Make sure the device was started properly. -- */ -+ /* Make sure the device was started properly. */ - if (sm_state == NULL) { - pr_err("[%s]: invalid device\n", __func__); - return; -@@ -978,8 +972,7 @@ static void vmcs_sm_host_walk_map_per_pid(int pid) - - mutex_lock(&(sm_state->map_lock)); - -- /* Log all applicable mapping(s). -- */ -+ /* Log all applicable mapping(s). */ - if (!list_empty(&sm_state->map_list)) { - list_for_each_entry(map, &sm_state->map_list, map_list) { - if (pid == -1 || map->res_pid == pid) { -@@ -995,15 +988,15 @@ static void vmcs_sm_host_walk_map_per_pid(int pid) - return; - } - --/* Dump the allocation table from host side point of view. This only dumps the --** data allocated for this process/device referenced by the file_data. --*/ -+/* -+ * Dump the allocation table from host side point of view. This only dumps the -+ * data allocated for this process/device referenced by the file_data. -+ */ - static void vmcs_sm_host_walk_alloc(struct SM_PRIV_DATA_T *file_data) - { - struct SM_RESOURCE_T *resource = NULL; - -- /* Make sure the device was started properly. -- */ -+ /* Make sure the device was started properly. */ - if ((sm_state == NULL) || (file_data == NULL)) { - pr_err("[%s]: invalid device\n", __func__); - return; -@@ -1026,8 +1019,7 @@ static void vmcs_sm_host_walk_alloc(struct SM_PRIV_DATA_T *file_data) - return; - } - --/* Create support for private data tracking. --*/ -+/* Create support for private data tracking. */ - static struct SM_PRIV_DATA_T *vc_sm_create_priv_data(pid_t id) - { - char alloc_name[32]; -@@ -1078,15 +1070,15 @@ static struct SM_PRIV_DATA_T *vc_sm_create_priv_data(pid_t id) - return file_data; - } - --/* Open the device. Creates a private state to help track all allocation --** associated with this device. --*/ -+/* -+ * Open the device. Creates a private state to help track all allocation -+ * associated with this device. -+ */ - static int vc_sm_open(struct inode *inode, struct file *file) - { - int ret = 0; - -- /* Make sure the device was started properly. -- */ -+ /* Make sure the device was started properly. */ - if (!sm_state) { - pr_err("[%s]: invalid device\n", __func__); - ret = -EPERM; -@@ -1105,9 +1097,10 @@ static int vc_sm_open(struct inode *inode, struct file *file) - return ret; - } - --/* Close the device. Free up all resources still associated with this device --** at the time. --*/ -+/* -+ * Close the device. Free up all resources still associated with this device -+ * at the time. -+ */ - static int vc_sm_release(struct inode *inode, struct file *file) - { - struct SM_PRIV_DATA_T *file_data = -@@ -1115,8 +1108,7 @@ static int vc_sm_release(struct inode *inode, struct file *file) - struct SM_RESOURCE_T *resource; - int ret = 0; - -- /* Make sure the device was started properly. -- */ -+ /* Make sure the device was started properly. */ - if (sm_state == NULL || file_data == NULL) { - pr_err("[%s]: invalid device\n", __func__); - ret = -EPERM; -@@ -1146,8 +1138,7 @@ static int vc_sm_release(struct inode *inode, struct file *file) - /* Remove the corresponding proc entry. */ - debugfs_remove_recursive(file_data->dir_pid); - -- /* Terminate the private data. -- */ -+ /* Terminate the private data. */ - kfree(file_data); - - out: -@@ -1175,8 +1166,7 @@ static void vcsm_vma_close(struct vm_area_struct *vma) - - map->ref_count--; - -- /* Remove from the map table. -- */ -+ /* Remove from the map table. */ - if (map->ref_count == 0) - vmcs_sm_remove_map(sm_state, map->resource, map); - } -@@ -1189,8 +1179,7 @@ static int vcsm_vma_fault(struct vm_fault *vmf) - unsigned long pfn; - int ret = 0; - -- /* Lock the resource if necessary. -- */ -+ /* Lock the resource if necessary. */ - if (!resource->lock_count) { - struct vc_sm_lock_unlock_t lock_unlock; - struct vc_sm_lock_result_t lock_result; -@@ -1203,8 +1192,7 @@ static int vcsm_vma_fault(struct vm_fault *vmf) - __func__, lock_unlock.res_handle, - (void *)lock_unlock.res_mem); - -- /* Lock the videocore allocated resource. -- */ -+ /* Lock the videocore allocated resource. */ - status = vc_vchi_sm_lock(sm_state->sm_handle, - &lock_unlock, &lock_result, 0); - if (status || !lock_result.res_mem) { -@@ -1221,8 +1209,7 @@ static int vcsm_vma_fault(struct vm_fault *vmf) - resource->res_stats[LOCK]++; - resource->lock_count++; - -- /* Keep track of the new base memory. -- */ -+ /* Keep track of the new base memory. */ - if (lock_result.res_mem && - lock_result.res_old_mem && - (lock_result.res_mem != lock_result.res_old_mem)) { -@@ -1244,9 +1231,9 @@ static int vcsm_vma_fault(struct vm_fault *vmf) - case 0: - case -ERESTARTSYS: - /* -- * EBUSY is ok: this just means that another thread -- * already did the job. -- */ -+ * EBUSY is ok: this just means that another thread -+ * already did the job. -+ */ - case -EBUSY: - return VM_FAULT_NOPAGE; - case -ENOMEM: -@@ -1324,8 +1311,7 @@ static void vcsm_vma_cache_clean_page_range(unsigned long addr, - } while (pgd++, addr = pgd_next, addr != end); - } - --/* Map an allocated data into something that the user space. --*/ -+/* Map an allocated data into something that the user space. */ - static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - { - int ret = 0; -@@ -1334,8 +1320,7 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - struct SM_RESOURCE_T *resource = NULL; - struct sm_mmap *map = NULL; - -- /* Make sure the device was started properly. -- */ -+ /* Make sure the device was started properly. */ - if ((sm_state == NULL) || (file_data == NULL)) { - pr_err("[%s]: invalid device\n", __func__); - return -EPERM; -@@ -1344,11 +1329,12 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - pr_debug("[%s]: private data %p, guid %x\n", __func__, file_data, - ((unsigned int)vma->vm_pgoff << PAGE_SHIFT)); - -- /* We lookup to make sure that the data we are being asked to mmap is -- ** something that we allocated. -- ** -- ** We use the offset information as the key to tell us which resource -- ** we are mapping. -+ /* -+ * We lookup to make sure that the data we are being asked to mmap is -+ * something that we allocated. -+ * -+ * We use the offset information as the key to tell us which resource -+ * we are mapping. - */ - resource = vmcs_sm_acquire_resource(file_data, - ((unsigned int)vma->vm_pgoff << -@@ -1363,8 +1349,7 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - __func__, resource->res_guid, current->tgid, resource->pid, - file_data->pid); - -- /* Check permissions. -- */ -+ /* Check permissions. */ - if (resource->pid && (resource->pid != current->tgid)) { - pr_err("[%s]: current tgid %u != %u owner\n", - __func__, current->tgid, resource->pid); -@@ -1372,8 +1357,7 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - goto error; - } - -- /* Verify that what we are asked to mmap is proper. -- */ -+ /* Verify that what we are asked to mmap is proper. */ - if (resource->res_size != (unsigned int)(vma->vm_end - vma->vm_start)) { - pr_err("[%s]: size inconsistency (resource: %u - mmap: %u)\n", - __func__, -@@ -1384,7 +1368,8 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - goto error; - } - -- /* Keep track of the tuple in the global resource list such that one -+ /* -+ * Keep track of the tuple in the global resource list such that one - * can do a mapping lookup for address/memory handle. - */ - map = kzalloc(sizeof(*map), GFP_KERNEL); -@@ -1403,8 +1388,9 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - map->vma = vma; - vmcs_sm_add_map(sm_state, resource, map); - -- /* We are not actually mapping the pages, we just provide a fault -- ** handler to allow pages to be mapped when accessed -+ /* -+ * We are not actually mapping the pages, we just provide a fault -+ * handler to allow pages to be mapped when accessed - */ - vma->vm_flags |= - VM_IO | VM_PFNMAP | VM_DONTCOPY | VM_DONTEXPAND; -@@ -1418,8 +1404,7 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - - if ((resource->res_cached == VMCS_SM_CACHE_NONE) || - (resource->res_cached == VMCS_SM_CACHE_VC)) { -- /* Allocated non host cached memory, honour it. -- */ -+ /* Allocated non host cached memory, honour it. */ - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - } - -@@ -1462,8 +1447,7 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - return ret; - } - --/* Allocate a shared memory handle and block. --*/ -+/* Allocate a shared memory handle and block. */ - int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_alloc *ioparam) - { -@@ -1505,8 +1489,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - __func__, alloc.name, alloc.type, ioparam->size, - alloc.base_unit, alloc.num_unit, alloc.alignement); - -- /* Allocate local resource to track this allocation. -- */ -+ /* Allocate local resource to track this allocation. */ - resource = kzalloc(sizeof(*resource), GFP_KERNEL); - if (!resource) { - ret = -ENOMEM; -@@ -1516,8 +1499,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - resource->ref_count++; - resource->pid = current->tgid; - -- /* Allocate the videocore resource. -- */ -+ /* Allocate the videocore resource. */ - status = vc_vchi_sm_alloc(sm_state->sm_handle, &alloc, &result, - &private->int_trans_id); - if (status == -EINTR) { -@@ -1535,8 +1517,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - goto error; - } - -- /* Keep track of the resource we created. -- */ -+ /* Keep track of the resource we created. */ - resource->private = private; - resource->res_handle = result.res_handle; - resource->res_base_mem = (void *)result.res_mem; -@@ -1544,7 +1525,8 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - resource->res_cached = cached; - resource->map = map; - -- /* Kernel/user GUID. This global identifier is used for mmap'ing the -+ /* -+ * Kernel/user GUID. This global identifier is used for mmap'ing the - * allocated region from user space, it is passed as the mmap'ing - * offset, we use it to 'hide' the videocore handle/address. - */ -@@ -1576,8 +1558,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - return ret; - } - --/* Share an allocate memory handle and block. --*/ -+/* Share an allocate memory handle and block.*/ - int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_alloc_share *ioparam) - { -@@ -1593,8 +1574,7 @@ int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, - goto error; - } - -- /* Allocate local resource to track this allocation. -- */ -+ /* Allocate local resource to track this allocation. */ - resource = kzalloc(sizeof(*resource), GFP_KERNEL); - if (resource == NULL) { - pr_err("[%s]: failed to allocate local tracking resource\n", -@@ -1606,8 +1586,7 @@ int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, - resource->ref_count++; - resource->pid = current->tgid; - -- /* Keep track of the resource we created. -- */ -+ /* Keep track of the resource we created. */ - resource->private = private; - resource->res_handle = shared_resource->res_handle; - resource->res_base_mem = shared_resource->res_base_mem; -@@ -1641,8 +1620,7 @@ int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, - return ret; - } - --/* Free a previously allocated shared memory handle and block. --*/ -+/* Free a previously allocated shared memory handle and block.*/ - static int vc_sm_ioctl_free(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_free *ioparam) - { -@@ -1655,8 +1633,7 @@ static int vc_sm_ioctl_free(struct SM_PRIV_DATA_T *private, - return -EINVAL; - } - -- /* Check permissions. -- */ -+ /* Check permissions. */ - if (resource->pid && (resource->pid != current->tgid)) { - pr_err("[%s]: current tgid %u != %u owner\n", - __func__, current->tgid, resource->pid); -@@ -1669,8 +1646,7 @@ static int vc_sm_ioctl_free(struct SM_PRIV_DATA_T *private, - return 0; - } - --/* Resize a previously allocated shared memory handle and block. --*/ -+/* Resize a previously allocated shared memory handle and block. */ - static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_resize *ioparam) - { -@@ -1679,8 +1655,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - struct vc_sm_resize_t resize; - struct SM_RESOURCE_T *resource; - -- /* Locate resource from GUID. -- */ -+ /* Locate resource from GUID. */ - resource = vmcs_sm_acquire_resource(private, ioparam->handle); - if (!resource) { - pr_err("[%s]: failed resource - guid %x\n", -@@ -1689,9 +1664,10 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - goto error; - } - -- /* If the resource is locked, its reference count will be not NULL, -- ** in which case we will not be allowed to resize it anyways, so -- ** reject the attempt here. -+ /* -+ * If the resource is locked, its reference count will be not NULL, -+ * in which case we will not be allowed to resize it anyways, so -+ * reject the attempt here. - */ - if (resource->lock_count != 0) { - pr_err("[%s]: cannot resize - guid %x, ref-cnt %d\n", -@@ -1700,8 +1676,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - goto error; - } - -- /* Check permissions. -- */ -+ /* Check permissions. */ - if (resource->pid && (resource->pid != current->tgid)) { - pr_err("[%s]: current tgid %u != %u owner\n", __func__, - current->tgid, resource->pid); -@@ -1724,8 +1699,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - __func__, ioparam->handle, resize.res_handle, - (void *)resize.res_mem); - -- /* Resize the videocore allocated resource. -- */ -+ /* Resize the videocore allocated resource. */ - status = vc_vchi_sm_resize(sm_state->sm_handle, &resize, - &private->int_trans_id); - if (status == -EINTR) { -@@ -1746,8 +1720,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - __func__, resize.res_handle, resource->res_size, - resize.res_new_size); - -- /* Successfully resized, save the information and inform the user. -- */ -+ /* Successfully resized, save the information and inform the user. */ - ioparam->old_size = resource->res_size; - resource->res_size = resize.res_new_size; - -@@ -1758,8 +1731,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - return ret; - } - --/* Lock a previously allocated shared memory handle and block. --*/ -+/* Lock a previously allocated shared memory handle and block. */ - static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_lock_unlock *ioparam, - int change_cache, enum vmcs_sm_cache_e cache_type, -@@ -1775,16 +1747,14 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - - map = NULL; - -- /* Locate resource from GUID. -- */ -+ /* Locate resource from GUID. */ - resource = vmcs_sm_acquire_resource(private, ioparam->handle); - if (resource == NULL) { - ret = -EINVAL; - goto error; - } - -- /* Check permissions. -- */ -+ /* Check permissions. */ - if (resource->pid && (resource->pid != current->tgid)) { - pr_err("[%s]: current tgid %u != %u owner\n", __func__, - current->tgid, resource->pid); -@@ -1795,15 +1765,13 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - lock.res_handle = resource->res_handle; - lock.res_mem = (uint32_t)resource->res_base_mem; - -- /* Take the lock and get the address to be mapped. -- */ -+ /* Take the lock and get the address to be mapped. */ - if (vc_addr == 0) { - pr_debug("[%s]: attempt to lock data - guid %x, hdl %x, base address %p\n", - __func__, ioparam->handle, lock.res_handle, - (void *)lock.res_mem); - -- /* Lock the videocore allocated resource. -- */ -+ /* Lock the videocore allocated resource. */ - status = vc_vchi_sm_lock(sm_state->sm_handle, &lock, &result, - &private->int_trans_id); - if (status == -EINTR) { -@@ -1826,24 +1794,21 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - __func__, lock.res_handle, (void *)result.res_mem, - (void *)lock.res_mem, resource->lock_count); - } -- /* Lock assumed taken already, address to be mapped is known. -- */ -+ /* Lock assumed taken already, address to be mapped is known. */ - else - resource->res_base_mem = (void *)vc_addr; - - resource->res_stats[LOCK]++; - resource->lock_count++; - -- /* Keep track of the new base memory allocation if it has changed. -- */ -+ /* Keep track of the new base memory allocation if it has changed. */ - if ((vc_addr == 0) && - ((void *)result.res_mem) && - ((void *)result.res_old_mem) && - (result.res_mem != result.res_old_mem)) { - resource->res_base_mem = (void *)result.res_mem; - -- /* Kernel allocated resources. -- */ -+ /* Kernel allocated resources. */ - if (resource->pid == 0) { - if (!list_empty(&resource->map_list)) { - list_for_each_entry_safe(map, map_tmp, -@@ -1875,8 +1840,7 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - __func__, resource->map_count, private->pid, - current->tgid, ioparam->handle, ioparam->addr); - } else { -- /* Kernel allocated resources. -- */ -+ /* Kernel allocated resources. */ - if (resource->pid == 0) { - pr_debug("[%s]: attempt mapping kernel resource - guid %x, hdl %x\n", - __func__, ioparam->handle, lock.res_handle); -@@ -1933,8 +1897,7 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - return ret; - } - --/* Unlock a previously allocated shared memory handle and block. --*/ -+/* Unlock a previously allocated shared memory handle and block.*/ - static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_lock_unlock *ioparam, - int flush, int wait_reply, int no_vc_unlock) -@@ -1947,16 +1910,14 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - - map = NULL; - -- /* Locate resource from GUID. -- */ -+ /* Locate resource from GUID. */ - resource = vmcs_sm_acquire_resource(private, ioparam->handle); - if (resource == NULL) { - ret = -EINVAL; - goto error; - } - -- /* Check permissions. -- */ -+ /* Check permissions. */ - if (resource->pid && (resource->pid != current->tgid)) { - pr_err("[%s]: current tgid %u != %u owner\n", - __func__, current->tgid, resource->pid); -@@ -1971,8 +1932,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - __func__, ioparam->handle, unlock.res_handle, - (void *)unlock.res_mem); - -- /* User space allocated resources. -- */ -+ /* User space allocated resources. */ - if (resource->pid) { - /* Flush if requested */ - if (resource->res_cached && flush) { -@@ -2071,12 +2031,10 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - } - - if (resource->lock_count) { -- /* Bypass the videocore unlock. -- */ -+ /* Bypass the videocore unlock. */ - if (no_vc_unlock) - status = 0; -- /* Unlock the videocore allocated resource. -- */ -+ /* Unlock the videocore allocated resource. */ - else { - status = - vc_vchi_sm_unlock(sm_state->sm_handle, &unlock, -@@ -2116,9 +2074,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - return ret; - } - --/* -- * Import a contiguous block of memory to be shared with VC. -- */ -+/* Import a contiguous block of memory to be shared with VC. */ - int vc_sm_ioctl_import_dmabuf(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_import_dmabuf *ioparam, - struct dma_buf *src_dma_buf) -@@ -2205,8 +2161,7 @@ int vc_sm_ioctl_import_dmabuf(struct SM_PRIV_DATA_T *private, - goto error; - } - -- /* Keep track of the resource we created. -- */ -+ /* Keep track of the resource we created. */ - resource->private = private; - resource->res_handle = result.res_handle; - resource->res_size = import.size; -@@ -2217,7 +2172,8 @@ int vc_sm_ioctl_import_dmabuf(struct SM_PRIV_DATA_T *private, - resource->sgt = sgt; - resource->dma_addr = sg_dma_address(sgt->sgl); - -- /* Kernel/user GUID. This global identifier is used for mmap'ing the -+ /* -+ * Kernel/user GUID. This global identifier is used for mmap'ing the - * allocated region from user space, it is passed as the mmap'ing - * offset, we use it to 'hide' the videocore handle/address. - */ -@@ -2282,8 +2238,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - file_data->restart_sys = 0; - } - -- /* Now process the command. -- */ -+ /* Now process the command. */ - switch (cmdnr) { - /* New memory allocation. - */ -@@ -2291,8 +2246,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - { - struct vmcs_sm_ioctl_alloc ioparam; - -- /* Get the parameter data. -- */ -+ /* Get the parameter data. */ - if (copy_from_user - (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2314,20 +2268,17 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - } - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; - -- /* Share existing memory allocation. -- */ -+ /* Share existing memory allocation. */ - case VMCS_SM_CMD_ALLOC_SHARE: - { - struct vmcs_sm_ioctl_alloc_share ioparam; - -- /* Get the parameter data. -- */ -+ /* Get the parameter data. */ - if (copy_from_user - (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2338,8 +2289,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - - ret = vc_sm_ioctl_alloc_share(file_data, &ioparam); - -- /* Copy result back to user. -- */ -+ /* Copy result back to user. */ - if (!ret - && copy_to_user((void *)arg, &ioparam, - sizeof(ioparam)) != 0) { -@@ -2352,8 +2302,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - } - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; -@@ -2362,8 +2311,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - { - struct vmcs_sm_ioctl_import_dmabuf ioparam; - -- /* Get the parameter data. -- */ -+ /* Get the parameter data. */ - if (copy_from_user - (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2386,21 +2334,18 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - } - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; - -- /* Lock (attempt to) *and* register a cache behavior change. -- */ -+ /* Lock (attempt to) *and* register a cache behavior change. */ - case VMCS_SM_CMD_LOCK_CACHE: - { - struct vmcs_sm_ioctl_lock_cache ioparam; - struct vmcs_sm_ioctl_lock_unlock lock; - -- /* Get parameter data. -- */ -+ /* Get parameter data. */ - if (copy_from_user - (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2414,20 +2359,17 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - vc_sm_ioctl_lock(file_data, &lock, 1, - ioparam.cached, 0); - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; - -- /* Lock (attempt to) existing memory allocation. -- */ -+ /* Lock (attempt to) existing memory allocation. */ - case VMCS_SM_CMD_LOCK: - { - struct vmcs_sm_ioctl_lock_unlock ioparam; - -- /* Get parameter data. -- */ -+ /* Get parameter data. */ - if (copy_from_user - (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2438,8 +2380,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - - ret = vc_sm_ioctl_lock(file_data, &ioparam, 0, 0, 0); - -- /* Copy result back to user. -- */ -+ /* Copy result back to user. */ - if (copy_to_user((void *)arg, &ioparam, sizeof(ioparam)) - != 0) { - pr_err("[%s]: failed to copy-to-user for cmd %x\n", -@@ -2447,20 +2388,17 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - } - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; - -- /* Unlock (attempt to) existing memory allocation. -- */ -+ /* Unlock (attempt to) existing memory allocation. */ - case VMCS_SM_CMD_UNLOCK: - { - struct vmcs_sm_ioctl_lock_unlock ioparam; - -- /* Get parameter data. -- */ -+ /* Get parameter data. */ - if (copy_from_user - (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2471,20 +2409,17 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - - ret = vc_sm_ioctl_unlock(file_data, &ioparam, 0, 1, 0); - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; - -- /* Resize (attempt to) existing memory allocation. -- */ -+ /* Resize (attempt to) existing memory allocation. */ - case VMCS_SM_CMD_RESIZE: - { - struct vmcs_sm_ioctl_resize ioparam; - -- /* Get parameter data. -- */ -+ /* Get parameter data. */ - if (copy_from_user - (&ioparam, (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2495,17 +2430,13 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - - ret = vc_sm_ioctl_resize(file_data, &ioparam); - -- /* Copy result back to user. -- */ -+ /* Copy result back to user. */ - if (copy_to_user((void *)arg, &ioparam, sizeof(ioparam)) - != 0) { - pr_err("[%s]: failed to copy-to-user for cmd %x\n", - __func__, cmdnr); - ret = -EFAULT; - } -- -- /* Done. -- */ - goto out; - } - break; -@@ -2550,7 +2481,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - goto out; - } - break; --/* Walk mapping table on host, information shows up in the -+ /* Walk mapping table on host, information shows up in the - ** kernel log. - */ - case VMCS_SM_CMD_HOST_WALK_MAP: -@@ -2589,7 +2520,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - { - struct vmcs_sm_ioctl_walk ioparam; - -- /* Get parameter data. */ -+ /* Get parameter data. */ - if (copy_from_user(&ioparam, - (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2646,8 +2577,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - { - struct vmcs_sm_ioctl_chk ioparam; - -- /* Get parameter data. -- */ -+ /* Get parameter data. */ - if (copy_from_user(&ioparam, - (void *)arg, sizeof(ioparam)) != 0) { - pr_err("[%s]: failed to copy-from-user for cmd %x\n", -@@ -2662,7 +2592,8 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - vmcs_sm_acquire_resource(file_data, ioparam.handle); - if (resource == NULL) - ret = -EINVAL; -- /* If the resource is cacheable, return additional -+ /* -+ * If the resource is cacheable, return additional - * information that may be needed to flush the cache. - */ - else if ((resource->res_cached == VMCS_SM_CACHE_HOST) || -@@ -2688,8 +2619,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - } - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; -@@ -2768,8 +2698,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - } - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; -@@ -2851,8 +2780,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - } - break; - -- /* Maps a user address given process and vc handle. -- */ -+ /* Maps a user address given process and vc handle. */ - case VMCS_SM_CMD_MAPPED_USR_ADDRESS: - { - struct vmcs_sm_ioctl_map ioparam; -@@ -2955,8 +2883,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - goto out; - } - -- /* Locate resource from GUID. -- */ -+ /* Locate resource from GUID. */ - resource = - vmcs_sm_acquire_resource(file_data, ioparam.handle); - -@@ -2992,8 +2919,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - if (resource) - vmcs_sm_release_resource(resource, 0); - -- /* Done. -- */ -+ /* Done. */ - goto out; - } - break; -@@ -3019,8 +2945,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - case 2: /* L1/L2 clean physical range */ - case 3: /* L1/L2 clean+invalidate all */ - { -- /* Locate resource from GUID. -- */ -+ /* Locate resource from GUID. */ - resource = - vmcs_sm_acquire_resource(file_data, ioparam.s[i].handle); - -@@ -3123,8 +3048,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - return ret; - } - --/* Device operations that we managed in this driver. --*/ -+/* Device operations that we managed in this driver. */ - static const struct file_operations vmcs_sm_ops = { - .owner = THIS_MODULE, - .unlocked_ioctl = vc_sm_ioctl, -@@ -3133,8 +3057,7 @@ static const struct file_operations vmcs_sm_ops = { - .mmap = vc_sm_mmap, - }; - --/* Creation of device. --*/ -+/* Creation of device. */ - static int vc_sm_create_sharedmemory(void) - { - int ret; -@@ -3144,8 +3067,7 @@ static int vc_sm_create_sharedmemory(void) - goto out; - } - -- /* Create a device class for creating dev nodes. -- */ -+ /* Create a device class for creating dev nodes. */ - sm_state->sm_class = class_create(THIS_MODULE, "vc-sm"); - if (IS_ERR(sm_state->sm_class)) { - pr_err("[%s]: unable to create device class\n", __func__); -@@ -3153,8 +3075,7 @@ static int vc_sm_create_sharedmemory(void) - goto out; - } - -- /* Create a character driver. -- */ -+ /* Create a character driver. */ - ret = alloc_chrdev_region(&sm_state->sm_devid, - DEVICE_MINOR, 1, DEVICE_NAME); - if (ret != 0) { -@@ -3169,8 +3090,7 @@ static int vc_sm_create_sharedmemory(void) - goto out_chrdev_unreg; - } - -- /* Create a device node. -- */ -+ /* Create a device node. */ - sm_state->sm_dev = device_create(sm_state->sm_class, - NULL, - MKDEV(MAJOR(sm_state->sm_devid), -@@ -3195,25 +3115,21 @@ static int vc_sm_create_sharedmemory(void) - return ret; - } - --/* Termination of the device. --*/ -+/* Termination of the device. */ - static int vc_sm_remove_sharedmemory(void) - { - int ret; - - if (sm_state == NULL) { -- /* Nothing to do. -- */ -+ /* Nothing to do. */ - ret = 0; - goto out; - } - -- /* Remove the sharedmemory character driver. -- */ -+ /* Remove the sharedmemory character driver. */ - cdev_del(&sm_state->sm_cdev); - -- /* Unregister region. -- */ -+ /* Unregister region. */ - unregister_chrdev_region(sm_state->sm_devid, 1); - - ret = 0; -@@ -3232,8 +3148,9 @@ static void vc_sm_connected_init(void) - - pr_info("[%s]: start\n", __func__); - -- /* Initialize and create a VCHI connection for the shared memory service -- ** running on videocore. -+ /* -+ * Initialize and create a VCHI connection for the shared memory service -+ * running on videocore. - */ - ret = vchi_initialise(&vchi_instance); - if (ret != 0) { -@@ -3306,8 +3223,7 @@ static void vc_sm_connected_init(void) - goto err_remove_shared_memory; - } - -- /* Done! -- */ -+ /* Done! */ - sm_inited = 1; - goto out; - -@@ -3344,20 +3260,16 @@ static int bcm2835_vcsm_remove(struct platform_device *pdev) - { - pr_debug("[%s]: start\n", __func__); - if (sm_inited) { -- /* Remove shared memory device. -- */ -+ /* Remove shared memory device. */ - vc_sm_remove_sharedmemory(); - -- /* Remove all proc entries. -- */ -+ /* Remove all proc entries. */ - debugfs_remove_recursive(sm_state->dir_root); - -- /* Stop the videocore shared memory service. -- */ -+ /* Stop the videocore shared memory service. */ - vc_vchi_sm_stop(&sm_state->sm_handle); - -- /* Free the memory for the state structure. -- */ -+ /* Free the memory for the state structure. */ - mutex_destroy(&(sm_state->map_lock)); - kfree(sm_state); - } -@@ -3374,8 +3286,7 @@ int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle) - int ret; - struct SM_RESOURCE_T *resource; - -- /* Validate we can work with this device. -- */ -+ /* Validate we can work with this device. */ - if (sm_state == NULL || alloc == NULL || handle == NULL) { - pr_err("[%s]: invalid input\n", __func__); - return -EPERM; -@@ -3396,8 +3307,7 @@ int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle) - resource->pid = 0; - vmcs_sm_release_resource(resource, 0); - -- /* Assign valid handle at this time. -- */ -+ /* Assign valid handle at this time. */ - *handle = ioparam.handle; - } else { - ret = -ENOMEM; -@@ -3408,22 +3318,19 @@ int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle) - } - EXPORT_SYMBOL_GPL(vc_sm_alloc); - --/* Get an internal resource handle mapped from the external one. --*/ -+/* Get an internal resource handle mapped from the external one. */ - int vc_sm_int_handle(int handle) - { - struct SM_RESOURCE_T *resource; - int ret = 0; - -- /* Validate we can work with this device. -- */ -+ /* Validate we can work with this device. */ - if (sm_state == NULL || handle == 0) { - pr_err("[%s]: invalid input\n", __func__); - return 0; - } - -- /* Locate resource from GUID. -- */ -+ /* Locate resource from GUID. */ - resource = vmcs_sm_acquire_resource(sm_state->data_knl, handle); - if (resource) { - ret = resource->res_handle; -@@ -3434,14 +3341,12 @@ int vc_sm_int_handle(int handle) - } - EXPORT_SYMBOL_GPL(vc_sm_int_handle); - --/* Free a previously allocated shared memory handle and block. --*/ -+/* Free a previously allocated shared memory handle and block. */ - int vc_sm_free(int handle) - { - struct vmcs_sm_ioctl_free ioparam = { handle }; - -- /* Validate we can work with this device. -- */ -+ /* Validate we can work with this device. */ - if (sm_state == NULL || handle == 0) { - pr_err("[%s]: invalid input\n", __func__); - return -EPERM; -@@ -3451,16 +3356,14 @@ int vc_sm_free(int handle) - } - EXPORT_SYMBOL_GPL(vc_sm_free); - --/* Lock a memory handle for use by kernel. --*/ -+/* Lock a memory handle for use by kernel. */ - int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, - long unsigned int *data) - { - struct vmcs_sm_ioctl_lock_unlock ioparam; - int ret; - -- /* Validate we can work with this device. -- */ -+ /* Validate we can work with this device. */ - if (sm_state == NULL || handle == 0 || data == NULL) { - pr_err("[%s]: invalid input\n", __func__); - return -EPERM; -@@ -3481,14 +3384,12 @@ int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, - } - EXPORT_SYMBOL_GPL(vc_sm_lock); - --/* Unlock a memory handle in use by kernel. --*/ -+/* Unlock a memory handle in use by kernel. */ - int vc_sm_unlock(int handle, int flush, int no_vc_unlock) - { - struct vmcs_sm_ioctl_lock_unlock ioparam; - -- /* Validate we can work with this device. -- */ -+ /* Validate we can work with this device. */ - if (sm_state == NULL || handle == 0) { - pr_err("[%s]: invalid input\n", __func__); - return -EPERM; -@@ -3500,16 +3401,14 @@ int vc_sm_unlock(int handle, int flush, int no_vc_unlock) - } - EXPORT_SYMBOL_GPL(vc_sm_unlock); - --/* Map a shared memory region for use by kernel. --*/ -+/* Map a shared memory region for use by kernel. */ - int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, - long unsigned int *data) - { - struct vmcs_sm_ioctl_lock_unlock ioparam; - int ret; - -- /* Validate we can work with this device. -- */ -+ /* Validate we can work with this device. */ - if (sm_state == NULL || handle == 0 || data == NULL || sm_addr == 0) { - pr_err("[%s]: invalid input\n", __func__); - return -EPERM; - -From c706af18d535efef6c572e801db4cb2e4626afe7 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:29:37 +0100 -Subject: [PATCH 186/199] vcsm: Fix indentation of switch/case statement. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 53 ++++++++++++++++++----------------- - 1 file changed, 27 insertions(+), 26 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index f93f18d3c24e43c9cf79e33f11cba9d1806f3124..9627a2b187130a68a15ea6fe46a72cf6cb5fe27e 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -2940,33 +2940,34 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - } - for (i=0; ires_cached) { -- unsigned long base = ioparam.s[i].addr & ~(PAGE_SIZE-1); -- unsigned long end = (ioparam.s[i].addr + ioparam.s[i].size + PAGE_SIZE-1) & ~(PAGE_SIZE-1); -- -- resource->res_stats[ioparam.s[i].cmd == 1 ? INVALID:FLUSH]++; -- -- /* L1/L2 cache flush */ -- down_read(¤t->mm->mmap_sem); -- vcsm_vma_cache_clean_page_range(base, end); -- up_read(¤t->mm->mmap_sem); -- } else if (resource == NULL) { -- ret = -EINVAL; -- goto out; -- } -- -- if (resource) -- vmcs_sm_release_resource(resource, 0); -+ default: -+ case 0: -+ break; /* NOOP */ -+ case 1: /* L1/L2 invalidate virtual range */ -+ case 2: /* L1/L2 clean physical range */ -+ case 3: /* L1/L2 clean+invalidate all */ -+ /* Locate resource from GUID. */ -+ resource = -+ vmcs_sm_acquire_resource(file_data, ioparam.s[i].handle); -+ -+ if ((resource != NULL) && resource->res_cached) { -+ unsigned long base = ioparam.s[i].addr & ~(PAGE_SIZE-1); -+ unsigned long end = (ioparam.s[i].addr + ioparam.s[i].size + PAGE_SIZE-1) & ~(PAGE_SIZE-1); -+ -+ resource->res_stats[ioparam.s[i].cmd == 1 ? INVALID:FLUSH]++; -+ -+ /* L1/L2 cache flush */ -+ down_read(¤t->mm->mmap_sem); -+ vcsm_vma_cache_clean_page_range(base, end); -+ up_read(¤t->mm->mmap_sem); -+ } else if (resource == NULL) { -+ ret = -EINVAL; -+ goto out; - } -+ -+ if (resource) -+ vmcs_sm_release_resource(resource, 0); -+ - break; - } - } - -From 4acacac866fa956ca26124fbc01784e9e19445d2 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:24:48 +0100 -Subject: [PATCH 187/199] vcsm: Fix spaces around operators. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 9627a2b187130a68a15ea6fe46a72cf6cb5fe27e..2b29c1f1ad611fe5ad04d0cf7c757370c850a5e9 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -2938,7 +2938,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - goto out; - } -- for (i=0; ires_cached) { -- unsigned long base = ioparam.s[i].addr & ~(PAGE_SIZE-1); -- unsigned long end = (ioparam.s[i].addr + ioparam.s[i].size + PAGE_SIZE-1) & ~(PAGE_SIZE-1); -+ unsigned long base = ioparam.s[i].addr & ~(PAGE_SIZE - 1); -+ unsigned long end = (ioparam.s[i].addr + ioparam.s[i].size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); - -- resource->res_stats[ioparam.s[i].cmd == 1 ? INVALID:FLUSH]++; -+ resource->res_stats[ioparam.s[i].cmd == 1 ? INVALID : FLUSH]++; - - /* L1/L2 cache flush */ - down_read(¤t->mm->mmap_sem); -@@ -3001,7 +3001,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - goto out; - } - -- for (i=0; iblock_count; ++j) { - -From 931ff674af5765891fd59828562907a4ef0a3e72 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:33:49 +0100 -Subject: [PATCH 188/199] vcsm: Fix use of S_IRUGO and use 0444 instead - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 2b29c1f1ad611fe5ad04d0cf7c757370c850a5e9..25dc958a35bac88e5ec6e0865d7cf35953d1b70b 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -1047,7 +1047,7 @@ static struct SM_PRIV_DATA_T *vc_sm_create_priv_data(pid_t id) - } else { - struct dentry *dir_entry; - -- dir_entry = debugfs_create_file(VC_SM_RESOURCES, S_IRUGO, -+ dir_entry = debugfs_create_file(VC_SM_RESOURCES, 0444, - file_data->dir_pid, file_data, - vc_sm_debug_fs_fops); - -@@ -1055,7 +1055,7 @@ static struct SM_PRIV_DATA_T *vc_sm_create_priv_data(pid_t id) - file_data->dir_res.priv_data = file_data; - file_data->dir_res.show = &vc_sm_alloc_show; - -- dir_entry = debugfs_create_file(VC_SM_STATS, S_IRUGO, -+ dir_entry = debugfs_create_file(VC_SM_STATS, 0444, - file_data->dir_pid, file_data, - vc_sm_debug_fs_fops); - -@@ -3194,12 +3194,12 @@ static void vc_sm_connected_init(void) - - sm_state->dir_state.show = &vc_sm_global_state_show; - sm_state->dir_state.dir_entry = debugfs_create_file(VC_SM_STATE, -- S_IRUGO, sm_state->dir_root, &sm_state->dir_state, -+ 0444, sm_state->dir_root, &sm_state->dir_state, - &vc_sm_debug_fs_fops); - - sm_state->dir_stats.show = &vc_sm_global_statistics_show; - sm_state->dir_stats.dir_entry = debugfs_create_file(VC_SM_STATS, -- S_IRUGO, sm_state->dir_root, &sm_state->dir_stats, -+ 0444, sm_state->dir_root, &sm_state->dir_stats, - &vc_sm_debug_fs_fops); - - /* Create the proc entry children. */ - -From fdd78a027d14bf60b26f8e89d8c8391c08b27bfc Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:36:11 +0100 -Subject: [PATCH 189/199] vcsm: Correct "long unsigned int" to "unsigned long" - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_sm_knl.h | 4 ++-- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 16 ++++++++-------- - 2 files changed, 10 insertions(+), 10 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_knl.h b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -index 8252d13999a78609fcc7e1bbe83307e2b1c1f8f1..8538f618ffd33b2901d220f3fb755aae6001e6d7 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_knl.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -@@ -36,7 +36,7 @@ int vc_sm_free(int handle); - - /* Lock a memory handle for use by kernel. */ - int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, -- long unsigned int *data); -+ unsigned long *data); - - /* Unlock a memory handle in use by kernel. */ - int vc_sm_unlock(int handle, int flush, int no_vc_unlock); -@@ -46,7 +46,7 @@ int vc_sm_int_handle(int handle); - - /* Map a shared memory region for use by kernel. */ - int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, -- long unsigned int *data); -+ unsigned long *data); - - /* Import a block of memory into the GPU space. */ - int vc_sm_import_dmabuf(struct dma_buf *dmabuf, int *handle); -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 25dc958a35bac88e5ec6e0865d7cf35953d1b70b..8244b365b690f8e2d00a8fae3754ce1f8bc23fbf 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -118,7 +118,7 @@ struct sm_mmap { - unsigned int res_vc_hdl; /* Resource handle (videocore). */ - unsigned int res_usr_hdl; /* Resource handle (user). */ - -- long unsigned int res_addr; /* Mapped virtual address. */ -+ unsigned long res_addr; /* Mapped virtual address. */ - struct vm_area_struct *vma; /* VM area for this mapping. */ - unsigned int ref_count; /* Reference count to this vma. */ - -@@ -1383,7 +1383,7 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - map->res_pid = current->tgid; - map->res_vc_hdl = resource->res_handle; - map->res_usr_hdl = resource->res_guid; -- map->res_addr = (long unsigned int)vma->vm_start; -+ map->res_addr = (unsigned long)vma->vm_start; - map->resource = resource; - map->vma = vma; - vmcs_sm_add_map(sm_state, resource, map); -@@ -1743,7 +1743,7 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - struct SM_RESOURCE_T *resource; - int ret = 0; - struct sm_mmap *map, *map_tmp; -- long unsigned int phys_addr; -+ unsigned long phys_addr; - - map = NULL; - -@@ -1859,7 +1859,7 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - phys_addr += mm_vc_mem_phys_addr; - if (resource->res_cached - == VMCS_SM_CACHE_HOST) { -- ioparam->addr = (long unsigned int) -+ ioparam->addr = (unsigned long) - /* TODO - make cached work */ - ioremap_nocache(phys_addr, - resource->res_size); -@@ -1868,7 +1868,7 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - __func__, ioparam->handle, - lock.res_handle, ioparam->addr); - } else { -- ioparam->addr = (long unsigned int) -+ ioparam->addr = (unsigned long) - ioremap_nocache(phys_addr, - resource->res_size); - -@@ -1995,7 +1995,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - if (flush && - (resource->res_cached == - VMCS_SM_CACHE_HOST)) { -- long unsigned int -+ unsigned long - phys_addr; - phys_addr = (uint32_t) - resource->res_base_mem & 0x3FFFFFFF; -@@ -3359,7 +3359,7 @@ EXPORT_SYMBOL_GPL(vc_sm_free); - - /* Lock a memory handle for use by kernel. */ - int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, -- long unsigned int *data) -+ unsigned long *data) - { - struct vmcs_sm_ioctl_lock_unlock ioparam; - int ret; -@@ -3404,7 +3404,7 @@ EXPORT_SYMBOL_GPL(vc_sm_unlock); - - /* Map a shared memory region for use by kernel. */ - int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, -- long unsigned int *data) -+ unsigned long *data) - { - struct vmcs_sm_ioctl_lock_unlock ioparam; - int ret; - -From efa2798b15577ed3143bc36cb63f75c66e986f6b Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:38:27 +0100 -Subject: [PATCH 190/199] vcsm: Fix "struct vm_operations_struct should - normally be const" - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 8244b365b690f8e2d00a8fae3754ce1f8bc23fbf..d8fe579a999d011d0af986a88398ac8b0947b7f3 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -1248,7 +1248,7 @@ static int vcsm_vma_fault(struct vm_fault *vmf) - } - } - --static struct vm_operations_struct vcsm_vm_ops = { -+static const struct vm_operations_struct vcsm_vm_ops = { - .open = vcsm_vma_open, - .close = vcsm_vma_close, - .fault = vcsm_vma_fault, - -From 7ade658e79c8be6151b3354f99efe3644318b26d Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:45:34 +0100 -Subject: [PATCH 191/199] vcsm: Fix "void function return statements are not - generally useful" - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 4 ---- - 1 file changed, 4 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index d8fe579a999d011d0af986a88398ac8b0947b7f3..ecff69dce678b5125b81ed82b74b950720c472b0 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -984,8 +984,6 @@ static void vmcs_sm_host_walk_map_per_pid(int pid) - } - - mutex_unlock(&(sm_state->map_lock)); -- -- return; - } - - /* -@@ -1015,8 +1013,6 @@ static void vmcs_sm_host_walk_alloc(struct SM_PRIV_DATA_T *file_data) - } - - mutex_unlock(&(sm_state->map_lock)); -- -- return; - } - - /* Create support for private data tracking. */ - -From fdba256e8df20dfb09579518f1eba063aab829e1 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:47:32 +0100 -Subject: [PATCH 192/199] vcsm: Fix "Prefer kcalloc over kzalloc with multiply" - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index ecff69dce678b5125b81ed82b74b950720c472b0..ea82a374a5e2ad51cefcfc20ea4265c436258646 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -2984,7 +2984,9 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - goto out; - } -- block = kzalloc(ioparam.op_count * sizeof(struct vmcs_sm_ioctl_clean_invalid_block), GFP_KERNEL); -+ block = kcalloc(ioparam.op_count, -+ sizeof(struct vmcs_sm_ioctl_clean_invalid_block), -+ GFP_KERNEL); - if (!block) { - ret = -EFAULT; - goto out; - -From 90f02b6982a289ed24252d07be2918e23e8fe891 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Fri, 1 Sep 2017 17:55:07 +0100 -Subject: [PATCH 193/199] vcsm: Remove VC_SM_LOCK_CACHE_MODE_T typedef. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vc_sm_knl.h | 11 +++++------ - drivers/char/broadcom/vc_sm/vmcs_sm.c | 6 +++--- - 2 files changed, 8 insertions(+), 9 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vc_sm_knl.h b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -index 8538f618ffd33b2901d220f3fb755aae6001e6d7..f7f74750d8358779c61dfcd6fc841aa1789a2c5e 100644 ---- a/drivers/char/broadcom/vc_sm/vc_sm_knl.h -+++ b/drivers/char/broadcom/vc_sm/vc_sm_knl.h -@@ -22,11 +22,10 @@ - #endif - - /* Type of memory to be locked (ie mapped) */ --typedef enum { -+enum vc_sm_lock_cache_mode { - VC_SM_LOCK_CACHED, - VC_SM_LOCK_NON_CACHED, -- --} VC_SM_LOCK_CACHE_MODE_T; -+}; - - /* Allocate a shared memory handle and block. */ - int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle); -@@ -35,7 +34,7 @@ int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle); - int vc_sm_free(int handle); - - /* Lock a memory handle for use by kernel. */ --int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, -+int vc_sm_lock(int handle, enum vc_sm_lock_cache_mode mode, - unsigned long *data); - - /* Unlock a memory handle in use by kernel. */ -@@ -45,8 +44,8 @@ int vc_sm_unlock(int handle, int flush, int no_vc_unlock); - int vc_sm_int_handle(int handle); - - /* Map a shared memory region for use by kernel. */ --int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, -- unsigned long *data); -+int vc_sm_map(int handle, unsigned int sm_addr, -+ enum vc_sm_lock_cache_mode mode, unsigned long *data); - - /* Import a block of memory into the GPU space. */ - int vc_sm_import_dmabuf(struct dma_buf *dmabuf, int *handle); -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index ea82a374a5e2ad51cefcfc20ea4265c436258646..b2452f3d0dfc207deed3703cb3ad43221af50b46 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -3356,7 +3356,7 @@ int vc_sm_free(int handle) - EXPORT_SYMBOL_GPL(vc_sm_free); - - /* Lock a memory handle for use by kernel. */ --int vc_sm_lock(int handle, VC_SM_LOCK_CACHE_MODE_T mode, -+int vc_sm_lock(int handle, enum vc_sm_lock_cache_mode mode, - unsigned long *data) - { - struct vmcs_sm_ioctl_lock_unlock ioparam; -@@ -3401,8 +3401,8 @@ int vc_sm_unlock(int handle, int flush, int no_vc_unlock) - EXPORT_SYMBOL_GPL(vc_sm_unlock); - - /* Map a shared memory region for use by kernel. */ --int vc_sm_map(int handle, unsigned int sm_addr, VC_SM_LOCK_CACHE_MODE_T mode, -- unsigned long *data) -+int vc_sm_map(int handle, unsigned int sm_addr, -+ enum vc_sm_lock_cache_mode mode, unsigned long *data) - { - struct vmcs_sm_ioctl_lock_unlock ioparam; - int ret; - -From d9b278599bab9340b5218c78f8183a0fc577f889 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Tue, 5 Sep 2017 10:12:21 +0100 -Subject: [PATCH 194/199] vcsm: Replace SM_RESOURCE_T with sm_resource_t - -Follow the Linux kernel coding style. - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 66 +++++++++++++++++------------------ - 1 file changed, 33 insertions(+), 33 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index b2452f3d0dfc207deed3703cb3ad43221af50b46..59e1239b42ba139e29b22017a1b2a669bec6b884 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -112,7 +112,7 @@ struct SM_PDE_T { - struct sm_mmap { - struct list_head map_list; /* Linked list of maps. */ - -- struct SM_RESOURCE_T *resource; /* Pointer to the resource. */ -+ struct sm_resource_t *resource; /* Pointer to the resource. */ - - pid_t res_pid; /* PID owning that resource. */ - unsigned int res_vc_hdl; /* Resource handle (videocore). */ -@@ -127,7 +127,7 @@ struct sm_mmap { - }; - - /* Single resource allocation tracked for each opened device. */ --struct SM_RESOURCE_T { -+struct sm_resource_t { - struct list_head resource_list; /* List of resources. */ - struct list_head global_resource_list; /* Global list of resources. */ - -@@ -140,7 +140,7 @@ struct SM_RESOURCE_T { - void *res_base_mem; /* Resource base memory address. */ - uint32_t res_size; /* Resource size allocated. */ - enum vmcs_sm_cache_e res_cached; /* Resource cache type. */ -- struct SM_RESOURCE_T *res_shared; /* Shared resource */ -+ struct sm_resource_t *res_shared; /* Shared resource */ - - enum SM_STATS_T res_stats[END_ALL]; /* Resource statistics. */ - -@@ -235,7 +235,7 @@ static inline unsigned int vcaddr_to_pfn(unsigned long vc_addr) - * Carries over to the state statistics the statistics once owned by a deceased - * resource. - */ --static void vc_sm_resource_deceased(struct SM_RESOURCE_T *p_res, int terminated) -+static void vc_sm_resource_deceased(struct sm_resource_t *p_res, int terminated) - { - if (sm_state != NULL) { - if (p_res != NULL) { -@@ -460,7 +460,7 @@ static unsigned int vmcs_sm_usr_address_from_pid_and_usr_handle(unsigned int - - /* Adds a resource mapping to the global data list. */ - static void vmcs_sm_add_map(struct SM_STATE_T *state, -- struct SM_RESOURCE_T *resource, struct sm_mmap *map) -+ struct sm_resource_t *resource, struct sm_mmap *map) - { - mutex_lock(&(state->map_lock)); - -@@ -480,7 +480,7 @@ static void vmcs_sm_add_map(struct SM_STATE_T *state, - - /* Removes a resource mapping from the global data list. */ - static void vmcs_sm_remove_map(struct SM_STATE_T *state, -- struct SM_RESOURCE_T *resource, -+ struct sm_resource_t *resource, - struct sm_mmap *map) - { - mutex_lock(&(state->map_lock)); -@@ -506,7 +506,7 @@ static void vmcs_sm_remove_map(struct SM_STATE_T *state, - static int vc_sm_global_state_show(struct seq_file *s, void *v) - { - struct sm_mmap *map = NULL; -- struct SM_RESOURCE_T *resource = NULL; -+ struct sm_resource_t *resource = NULL; - int map_count = 0; - int resource_count = 0; - -@@ -634,7 +634,7 @@ static int vc_sm_statistics_show(struct seq_file *s, void *v) - { - int ix; - struct SM_PRIV_DATA_T *file_data; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - int res_count = 0; - struct SM_PDE_T *p_pde; - -@@ -691,7 +691,7 @@ static int vc_sm_statistics_show(struct seq_file *s, void *v) - static int vc_sm_alloc_show(struct seq_file *s, void *v) - { - struct SM_PRIV_DATA_T *file_data; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - int alloc_count = 0; - struct SM_PDE_T *p_pde; - -@@ -765,7 +765,7 @@ static const struct file_operations vc_sm_debug_fs_fops = { - * data. - */ - static void vmcs_sm_add_resource(struct SM_PRIV_DATA_T *privdata, -- struct SM_RESOURCE_T *resource) -+ struct sm_resource_t *resource) - { - mutex_lock(&(sm_state->map_lock)); - list_add(&resource->resource_list, &privdata->resource_list); -@@ -781,11 +781,11 @@ static void vmcs_sm_add_resource(struct SM_PRIV_DATA_T *privdata, - * Locates a resource and acquire a reference on it. - * The resource won't be deleted while there is a reference on it. - */ --static struct SM_RESOURCE_T *vmcs_sm_acquire_resource(struct SM_PRIV_DATA_T -+static struct sm_resource_t *vmcs_sm_acquire_resource(struct SM_PRIV_DATA_T - *private, - unsigned int res_guid) - { -- struct SM_RESOURCE_T *resource, *ret = NULL; -+ struct sm_resource_t *resource, *ret = NULL; - - mutex_lock(&(sm_state->map_lock)); - -@@ -811,10 +811,10 @@ static struct SM_RESOURCE_T *vmcs_sm_acquire_resource(struct SM_PRIV_DATA_T - * Locates a resource and acquire a reference on it. - * The resource won't be deleted while there is a reference on it. - */ --static struct SM_RESOURCE_T *vmcs_sm_acquire_first_resource( -+static struct sm_resource_t *vmcs_sm_acquire_first_resource( - struct SM_PRIV_DATA_T *private) - { -- struct SM_RESOURCE_T *resource, *ret = NULL; -+ struct sm_resource_t *resource, *ret = NULL; - - mutex_lock(&(sm_state->map_lock)); - -@@ -837,10 +837,10 @@ static struct SM_RESOURCE_T *vmcs_sm_acquire_first_resource( - * Locates a resource and acquire a reference on it. - * The resource won't be deleted while there is a reference on it. - */ --static struct SM_RESOURCE_T *vmcs_sm_acquire_global_resource(unsigned int -+static struct sm_resource_t *vmcs_sm_acquire_global_resource(unsigned int - res_guid) - { -- struct SM_RESOURCE_T *resource, *ret = NULL; -+ struct sm_resource_t *resource, *ret = NULL; - - mutex_lock(&(sm_state->map_lock)); - -@@ -867,11 +867,11 @@ static struct SM_RESOURCE_T *vmcs_sm_acquire_global_resource(unsigned int - * Release a previously acquired resource. - * The resource will be deleted when its refcount reaches 0. - */ --static void vmcs_sm_release_resource(struct SM_RESOURCE_T *resource, int force) -+static void vmcs_sm_release_resource(struct sm_resource_t *resource, int force) - { - struct SM_PRIV_DATA_T *private = resource->private; - struct sm_mmap *map, *map_tmp; -- struct SM_RESOURCE_T *res_tmp; -+ struct sm_resource_t *res_tmp; - int ret; - - mutex_lock(&(sm_state->map_lock)); -@@ -992,7 +992,7 @@ static void vmcs_sm_host_walk_map_per_pid(int pid) - */ - static void vmcs_sm_host_walk_alloc(struct SM_PRIV_DATA_T *file_data) - { -- struct SM_RESOURCE_T *resource = NULL; -+ struct sm_resource_t *resource = NULL; - - /* Make sure the device was started properly. */ - if ((sm_state == NULL) || (file_data == NULL)) { -@@ -1101,7 +1101,7 @@ static int vc_sm_release(struct inode *inode, struct file *file) - { - struct SM_PRIV_DATA_T *file_data = - (struct SM_PRIV_DATA_T *)file->private_data; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - int ret = 0; - - /* Make sure the device was started properly. */ -@@ -1170,7 +1170,7 @@ static void vcsm_vma_close(struct vm_area_struct *vma) - static int vcsm_vma_fault(struct vm_fault *vmf) - { - struct sm_mmap *map = (struct sm_mmap *)vmf->vma->vm_private_data; -- struct SM_RESOURCE_T *resource = map->resource; -+ struct sm_resource_t *resource = map->resource; - pgoff_t page_offset; - unsigned long pfn; - int ret = 0; -@@ -1313,7 +1313,7 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - int ret = 0; - struct SM_PRIV_DATA_T *file_data = - (struct SM_PRIV_DATA_T *)file->private_data; -- struct SM_RESOURCE_T *resource = NULL; -+ struct sm_resource_t *resource = NULL; - struct sm_mmap *map = NULL; - - /* Make sure the device was started properly. */ -@@ -1449,7 +1449,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - { - int ret = 0; - int status; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - struct vc_sm_alloc_t alloc = { 0 }; - struct vc_sm_alloc_result_t result = { 0 }; - enum vmcs_sm_cache_e cached = ioparam->cached; -@@ -1558,7 +1558,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_alloc_share *ioparam) - { -- struct SM_RESOURCE_T *resource, *shared_resource; -+ struct sm_resource_t *resource, *shared_resource; - int ret = 0; - - pr_debug("[%s]: attempt to share resource %u\n", __func__, -@@ -1620,7 +1620,7 @@ int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, - static int vc_sm_ioctl_free(struct SM_PRIV_DATA_T *private, - struct vmcs_sm_ioctl_free *ioparam) - { -- struct SM_RESOURCE_T *resource = -+ struct sm_resource_t *resource = - vmcs_sm_acquire_resource(private, ioparam->handle); - - if (resource == NULL) { -@@ -1649,7 +1649,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - int ret = 0; - int status; - struct vc_sm_resize_t resize; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - - /* Locate resource from GUID. */ - resource = vmcs_sm_acquire_resource(private, ioparam->handle); -@@ -1736,7 +1736,7 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - int status; - struct vc_sm_lock_unlock_t lock; - struct vc_sm_lock_result_t result; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - int ret = 0; - struct sm_mmap *map, *map_tmp; - unsigned long phys_addr; -@@ -1901,7 +1901,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - int status; - struct vc_sm_lock_unlock_t unlock; - struct sm_mmap *map, *map_tmp; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - int ret = 0; - - map = NULL; -@@ -2077,7 +2077,7 @@ int vc_sm_ioctl_import_dmabuf(struct SM_PRIV_DATA_T *private, - { - int ret = 0; - int status; -- struct SM_RESOURCE_T *resource = NULL; -+ struct sm_resource_t *resource = NULL; - struct vc_sm_import import = { 0 }; - struct vc_sm_import_result result = { 0 }; - struct dma_buf *dma_buf; -@@ -2206,7 +2206,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - unsigned int cmdnr = _IOC_NR(cmd); - struct SM_PRIV_DATA_T *file_data = - (struct SM_PRIV_DATA_T *)file->private_data; -- struct SM_RESOURCE_T *resource = NULL; -+ struct sm_resource_t *resource = NULL; - - /* Validate we can work with this device. */ - if ((sm_state == NULL) || (file_data == NULL)) { -@@ -3283,7 +3283,7 @@ int vc_sm_alloc(struct vc_sm_alloc_t *alloc, int *handle) - { - struct vmcs_sm_ioctl_alloc ioparam = { 0 }; - int ret; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - - /* Validate we can work with this device. */ - if (sm_state == NULL || alloc == NULL || handle == NULL) { -@@ -3320,7 +3320,7 @@ EXPORT_SYMBOL_GPL(vc_sm_alloc); - /* Get an internal resource handle mapped from the external one. */ - int vc_sm_int_handle(int handle) - { -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - int ret = 0; - - /* Validate we can work with this device. */ -@@ -3433,7 +3433,7 @@ int vc_sm_import_dmabuf(struct dma_buf *dmabuf, int *handle) - { - struct vmcs_sm_ioctl_import_dmabuf ioparam = { 0 }; - int ret; -- struct SM_RESOURCE_T *resource; -+ struct sm_resource_t *resource; - - /* Validate we can work with this device. */ - if (!sm_state || !dmabuf || !handle) { - -From ec71f864e5976f147727465843d2a46836aaed1e Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Tue, 5 Sep 2017 10:15:25 +0100 -Subject: [PATCH 195/199] vcsm: Replace SM_STATS_T with sm_stats_t - -Follows the kernel coding style - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 59e1239b42ba139e29b22017a1b2a669bec6b884..08567b018a63cb783d1e66056f64b2d888f10315 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -62,7 +62,7 @@ - #define VC_SM_WRITE_BUF_SIZE 128 - - /* Statistics tracked per resource and globally. */ --enum SM_STATS_T { -+enum sm_stats_t { - /* Attempt. */ - ALLOC, - FREE, -@@ -142,7 +142,7 @@ struct sm_resource_t { - enum vmcs_sm_cache_e res_cached; /* Resource cache type. */ - struct sm_resource_t *res_shared; /* Shared resource */ - -- enum SM_STATS_T res_stats[END_ALL]; /* Resource statistics. */ -+ enum sm_stats_t res_stats[END_ALL]; /* Resource statistics. */ - - uint8_t map_count; /* Counter of mappings for this resource. */ - struct list_head map_list; /* Maps associated with a resource. */ -@@ -187,8 +187,8 @@ struct SM_STATE_T { - struct list_head map_list; /* List of maps. */ - struct list_head resource_list; /* List of resources. */ - -- enum SM_STATS_T deceased[END_ALL]; /* Natural termination stats. */ -- enum SM_STATS_T terminated[END_ALL]; /* Forced termination stats. */ -+ enum sm_stats_t deceased[END_ALL]; /* Natural termination stats. */ -+ enum sm_stats_t terminated[END_ALL]; /* Forced termination stats. */ - uint32_t res_deceased_cnt; /* Natural termination counter. */ - uint32_t res_terminated_cnt; /* Forced termination counter. */ - - -From e481434fe4b5187aad8f25257fcc16fbf30b569e Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Tue, 5 Sep 2017 10:16:07 +0100 -Subject: [PATCH 196/199] vcsm: Replace SM_STATE_T with sm_state_t - -Follow the Linux kernel coding style - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 08567b018a63cb783d1e66056f64b2d888f10315..39c64c38ce7638592eeb98583fdb2ddee981a9ec 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -174,7 +174,7 @@ struct SM_PRIV_DATA_T { - }; - - /* Global state information. */ --struct SM_STATE_T { -+struct sm_state_t { - struct platform_device *pdev; - struct sm_instance *sm_handle; /* Handle for videocore service. */ - struct dentry *dir_root; /* Debug fs entries root. */ -@@ -206,7 +206,7 @@ struct SM_STATE_T { - - /* ---- Private Variables ----------------------------------------------- */ - --static struct SM_STATE_T *sm_state; -+static struct sm_state_t *sm_state; - static int sm_inited; - - #if 0 -@@ -459,7 +459,7 @@ static unsigned int vmcs_sm_usr_address_from_pid_and_usr_handle(unsigned int - } - - /* Adds a resource mapping to the global data list. */ --static void vmcs_sm_add_map(struct SM_STATE_T *state, -+static void vmcs_sm_add_map(struct sm_state_t *state, - struct sm_resource_t *resource, struct sm_mmap *map) - { - mutex_lock(&(state->map_lock)); -@@ -479,7 +479,7 @@ static void vmcs_sm_add_map(struct SM_STATE_T *state, - } - - /* Removes a resource mapping from the global data list. */ --static void vmcs_sm_remove_map(struct SM_STATE_T *state, -+static void vmcs_sm_remove_map(struct sm_state_t *state, - struct sm_resource_t *resource, - struct sm_mmap *map) - { - -From 7268cef4b7ded9a72301d42efc6c8449b12be89b Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Tue, 5 Sep 2017 10:17:18 +0100 -Subject: [PATCH 197/199] vcsm: Replace SM_PRIV_DATA_T with sm_priv_data_t - -Follows the Linux kernel coding style - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 54 +++++++++++++++++------------------ - 1 file changed, 27 insertions(+), 27 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 39c64c38ce7638592eeb98583fdb2ddee981a9ec..9f1ea8269385b9c2cf4f7ab0ca6ba99b3ca12b6c 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -153,12 +153,12 @@ struct sm_resource_t { - struct sg_table *sgt; - dma_addr_t dma_addr; - -- struct SM_PRIV_DATA_T *private; -+ struct sm_priv_data_t *private; - bool map; /* whether to map pages up front */ - }; - - /* Private file data associated with each opened device. */ --struct SM_PRIV_DATA_T { -+struct sm_priv_data_t { - struct list_head resource_list; /* List of resources. */ - - pid_t pid; /* PID of creator. */ -@@ -197,7 +197,7 @@ struct sm_state_t { - struct class *sm_class; /* Class. */ - struct device *sm_dev; /* Device. */ - -- struct SM_PRIV_DATA_T *data_knl; /* Kernel internal data tracking. */ -+ struct sm_priv_data_t *data_knl; /* Kernel internal data tracking. */ - - struct mutex lock; /* Global lock. */ - uint32_t guid; /* GUID (next) tracker. */ -@@ -633,13 +633,13 @@ static int vc_sm_global_statistics_show(struct seq_file *s, void *v) - static int vc_sm_statistics_show(struct seq_file *s, void *v) - { - int ix; -- struct SM_PRIV_DATA_T *file_data; -+ struct sm_priv_data_t *file_data; - struct sm_resource_t *resource; - int res_count = 0; - struct SM_PDE_T *p_pde; - - p_pde = (struct SM_PDE_T *)(s->private); -- file_data = (struct SM_PRIV_DATA_T *)(p_pde->priv_data); -+ file_data = (struct sm_priv_data_t *)(p_pde->priv_data); - - if (file_data == NULL) - return 0; -@@ -690,13 +690,13 @@ static int vc_sm_statistics_show(struct seq_file *s, void *v) - /* Read callback for the allocation proc entry. */ - static int vc_sm_alloc_show(struct seq_file *s, void *v) - { -- struct SM_PRIV_DATA_T *file_data; -+ struct sm_priv_data_t *file_data; - struct sm_resource_t *resource; - int alloc_count = 0; - struct SM_PDE_T *p_pde; - - p_pde = (struct SM_PDE_T *)(s->private); -- file_data = (struct SM_PRIV_DATA_T *)(p_pde->priv_data); -+ file_data = (struct sm_priv_data_t *)(p_pde->priv_data); - - if (!file_data) - return 0; -@@ -764,7 +764,7 @@ static const struct file_operations vc_sm_debug_fs_fops = { - * Adds a resource to the private data list which tracks all the allocated - * data. - */ --static void vmcs_sm_add_resource(struct SM_PRIV_DATA_T *privdata, -+static void vmcs_sm_add_resource(struct sm_priv_data_t *privdata, - struct sm_resource_t *resource) - { - mutex_lock(&(sm_state->map_lock)); -@@ -781,7 +781,7 @@ static void vmcs_sm_add_resource(struct SM_PRIV_DATA_T *privdata, - * Locates a resource and acquire a reference on it. - * The resource won't be deleted while there is a reference on it. - */ --static struct sm_resource_t *vmcs_sm_acquire_resource(struct SM_PRIV_DATA_T -+static struct sm_resource_t *vmcs_sm_acquire_resource(struct sm_priv_data_t - *private, - unsigned int res_guid) - { -@@ -812,7 +812,7 @@ static struct sm_resource_t *vmcs_sm_acquire_resource(struct SM_PRIV_DATA_T - * The resource won't be deleted while there is a reference on it. - */ - static struct sm_resource_t *vmcs_sm_acquire_first_resource( -- struct SM_PRIV_DATA_T *private) -+ struct sm_priv_data_t *private) - { - struct sm_resource_t *resource, *ret = NULL; - -@@ -869,7 +869,7 @@ static struct sm_resource_t *vmcs_sm_acquire_global_resource(unsigned int - */ - static void vmcs_sm_release_resource(struct sm_resource_t *resource, int force) - { -- struct SM_PRIV_DATA_T *private = resource->private; -+ struct sm_priv_data_t *private = resource->private; - struct sm_mmap *map, *map_tmp; - struct sm_resource_t *res_tmp; - int ret; -@@ -990,7 +990,7 @@ static void vmcs_sm_host_walk_map_per_pid(int pid) - * Dump the allocation table from host side point of view. This only dumps the - * data allocated for this process/device referenced by the file_data. - */ --static void vmcs_sm_host_walk_alloc(struct SM_PRIV_DATA_T *file_data) -+static void vmcs_sm_host_walk_alloc(struct sm_priv_data_t *file_data) - { - struct sm_resource_t *resource = NULL; - -@@ -1016,10 +1016,10 @@ static void vmcs_sm_host_walk_alloc(struct SM_PRIV_DATA_T *file_data) - } - - /* Create support for private data tracking. */ --static struct SM_PRIV_DATA_T *vc_sm_create_priv_data(pid_t id) -+static struct sm_priv_data_t *vc_sm_create_priv_data(pid_t id) - { - char alloc_name[32]; -- struct SM_PRIV_DATA_T *file_data = NULL; -+ struct sm_priv_data_t *file_data = NULL; - - /* Allocate private structure. */ - file_data = kzalloc(sizeof(*file_data), GFP_KERNEL); -@@ -1099,8 +1099,8 @@ static int vc_sm_open(struct inode *inode, struct file *file) - */ - static int vc_sm_release(struct inode *inode, struct file *file) - { -- struct SM_PRIV_DATA_T *file_data = -- (struct SM_PRIV_DATA_T *)file->private_data; -+ struct sm_priv_data_t *file_data = -+ (struct sm_priv_data_t *)file->private_data; - struct sm_resource_t *resource; - int ret = 0; - -@@ -1311,8 +1311,8 @@ static void vcsm_vma_cache_clean_page_range(unsigned long addr, - static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - { - int ret = 0; -- struct SM_PRIV_DATA_T *file_data = -- (struct SM_PRIV_DATA_T *)file->private_data; -+ struct sm_priv_data_t *file_data = -+ (struct sm_priv_data_t *)file->private_data; - struct sm_resource_t *resource = NULL; - struct sm_mmap *map = NULL; - -@@ -1444,7 +1444,7 @@ static int vc_sm_mmap(struct file *file, struct vm_area_struct *vma) - } - - /* Allocate a shared memory handle and block. */ --int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, -+int vc_sm_ioctl_alloc(struct sm_priv_data_t *private, - struct vmcs_sm_ioctl_alloc *ioparam) - { - int ret = 0; -@@ -1555,7 +1555,7 @@ int vc_sm_ioctl_alloc(struct SM_PRIV_DATA_T *private, - } - - /* Share an allocate memory handle and block.*/ --int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, -+int vc_sm_ioctl_alloc_share(struct sm_priv_data_t *private, - struct vmcs_sm_ioctl_alloc_share *ioparam) - { - struct sm_resource_t *resource, *shared_resource; -@@ -1617,7 +1617,7 @@ int vc_sm_ioctl_alloc_share(struct SM_PRIV_DATA_T *private, - } - - /* Free a previously allocated shared memory handle and block.*/ --static int vc_sm_ioctl_free(struct SM_PRIV_DATA_T *private, -+static int vc_sm_ioctl_free(struct sm_priv_data_t *private, - struct vmcs_sm_ioctl_free *ioparam) - { - struct sm_resource_t *resource = -@@ -1643,7 +1643,7 @@ static int vc_sm_ioctl_free(struct SM_PRIV_DATA_T *private, - } - - /* Resize a previously allocated shared memory handle and block. */ --static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, -+static int vc_sm_ioctl_resize(struct sm_priv_data_t *private, - struct vmcs_sm_ioctl_resize *ioparam) - { - int ret = 0; -@@ -1728,7 +1728,7 @@ static int vc_sm_ioctl_resize(struct SM_PRIV_DATA_T *private, - } - - /* Lock a previously allocated shared memory handle and block. */ --static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, -+static int vc_sm_ioctl_lock(struct sm_priv_data_t *private, - struct vmcs_sm_ioctl_lock_unlock *ioparam, - int change_cache, enum vmcs_sm_cache_e cache_type, - unsigned int vc_addr) -@@ -1894,7 +1894,7 @@ static int vc_sm_ioctl_lock(struct SM_PRIV_DATA_T *private, - } - - /* Unlock a previously allocated shared memory handle and block.*/ --static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, -+static int vc_sm_ioctl_unlock(struct sm_priv_data_t *private, - struct vmcs_sm_ioctl_lock_unlock *ioparam, - int flush, int wait_reply, int no_vc_unlock) - { -@@ -2071,7 +2071,7 @@ static int vc_sm_ioctl_unlock(struct SM_PRIV_DATA_T *private, - } - - /* Import a contiguous block of memory to be shared with VC. */ --int vc_sm_ioctl_import_dmabuf(struct SM_PRIV_DATA_T *private, -+int vc_sm_ioctl_import_dmabuf(struct sm_priv_data_t *private, - struct vmcs_sm_ioctl_import_dmabuf *ioparam, - struct dma_buf *src_dma_buf) - { -@@ -2204,8 +2204,8 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - { - int ret = 0; - unsigned int cmdnr = _IOC_NR(cmd); -- struct SM_PRIV_DATA_T *file_data = -- (struct SM_PRIV_DATA_T *)file->private_data; -+ struct sm_priv_data_t *file_data = -+ (struct sm_priv_data_t *)file->private_data; - struct sm_resource_t *resource = NULL; - - /* Validate we can work with this device. */ - -From 68735673c349b79d33822bfe91fc98e54b99f3b9 Mon Sep 17 00:00:00 2001 -From: Dave Stevenson -Date: Tue, 5 Sep 2017 10:18:33 +0100 -Subject: [PATCH 198/199] vcsm: Replace SM_PDE_T with sm_pde_t - -Follows the Linux kernel coding style - -Signed-off-by: Dave Stevenson ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 22 +++++++++++----------- - 1 file changed, 11 insertions(+), 11 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 9f1ea8269385b9c2cf4f7ab0ca6ba99b3ca12b6c..160e109d780a7badda9e5474a9d38fa9794d0298 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -101,7 +101,7 @@ static const char *const sm_stats_human_read[] = { - }; - - typedef int (*VC_SM_SHOW) (struct seq_file *s, void *v); --struct SM_PDE_T { -+struct sm_pde_t { - VC_SM_SHOW show; /* Debug fs function hookup. */ - struct dentry *dir_entry; /* Debug fs directory entry. */ - void *priv_data; /* Private data */ -@@ -164,8 +164,8 @@ struct sm_priv_data_t { - pid_t pid; /* PID of creator. */ - - struct dentry *dir_pid; /* Debug fs entries root. */ -- struct SM_PDE_T dir_stats; /* Debug fs entries statistics sub-tree. */ -- struct SM_PDE_T dir_res; /* Debug fs resource sub-tree. */ -+ struct sm_pde_t dir_stats; /* Debug fs entries statistics sub-tree. */ -+ struct sm_pde_t dir_res; /* Debug fs resource sub-tree. */ - - int restart_sys; /* Tracks restart on interrupt. */ - enum vc_sm_msg_type int_action; /* Interrupted action. */ -@@ -179,8 +179,8 @@ struct sm_state_t { - struct sm_instance *sm_handle; /* Handle for videocore service. */ - struct dentry *dir_root; /* Debug fs entries root. */ - struct dentry *dir_alloc; /* Debug fs entries allocations. */ -- struct SM_PDE_T dir_stats; /* Debug fs entries statistics sub-tree. */ -- struct SM_PDE_T dir_state; /* Debug fs entries state sub-tree. */ -+ struct sm_pde_t dir_stats; /* Debug fs entries statistics sub-tree. */ -+ struct sm_pde_t dir_state; /* Debug fs entries state sub-tree. */ - struct dentry *debug; /* Debug fs entries debug. */ - - struct mutex map_lock; /* Global map lock. */ -@@ -636,9 +636,9 @@ static int vc_sm_statistics_show(struct seq_file *s, void *v) - struct sm_priv_data_t *file_data; - struct sm_resource_t *resource; - int res_count = 0; -- struct SM_PDE_T *p_pde; -+ struct sm_pde_t *p_pde; - -- p_pde = (struct SM_PDE_T *)(s->private); -+ p_pde = (struct sm_pde_t *)(s->private); - file_data = (struct sm_priv_data_t *)(p_pde->priv_data); - - if (file_data == NULL) -@@ -693,9 +693,9 @@ static int vc_sm_alloc_show(struct seq_file *s, void *v) - struct sm_priv_data_t *file_data; - struct sm_resource_t *resource; - int alloc_count = 0; -- struct SM_PDE_T *p_pde; -+ struct sm_pde_t *p_pde; - -- p_pde = (struct SM_PDE_T *)(s->private); -+ p_pde = (struct sm_pde_t *)(s->private); - file_data = (struct sm_priv_data_t *)(p_pde->priv_data); - - if (!file_data) -@@ -738,9 +738,9 @@ static int vc_sm_alloc_show(struct seq_file *s, void *v) - - static int vc_sm_seq_file_show(struct seq_file *s, void *v) - { -- struct SM_PDE_T *sm_pde; -+ struct sm_pde_t *sm_pde; - -- sm_pde = (struct SM_PDE_T *)(s->private); -+ sm_pde = (struct sm_pde_t *)(s->private); - - if (sm_pde && sm_pde->show) - sm_pde->show(s, v); - -From 09d3e47d84e7ac57fac2c90607e8a6dda0b82c40 Mon Sep 17 00:00:00 2001 -From: popcornmix -Date: Tue, 5 Sep 2017 16:24:03 +0100 -Subject: [PATCH 199/199] vcsm: Handle the clean+invalidate case directly - ---- - drivers/char/broadcom/vc_sm/vmcs_sm.c | 66 +++++++++++++++++++++-------------- - 1 file changed, 39 insertions(+), 27 deletions(-) - -diff --git a/drivers/char/broadcom/vc_sm/vmcs_sm.c b/drivers/char/broadcom/vc_sm/vmcs_sm.c -index 160e109d780a7badda9e5474a9d38fa9794d0298..034ae2f27f870621af9f49453501f1cde051f32a 100644 ---- a/drivers/char/broadcom/vc_sm/vmcs_sm.c -+++ b/drivers/char/broadcom/vc_sm/vmcs_sm.c -@@ -218,6 +218,32 @@ static const char *const sm_cache_map_vector[] = { - }; - #endif - -+typedef void cache_flush_op_fn(const void *, const void *); -+ -+#if defined(CONFIG_CPU_CACHE_V7) -+extern cache_flush_op_fn v7_dma_inv_range; -+extern cache_flush_op_fn v7_dma_clean_range; -+static cache_flush_op_fn * const flushops[4] = -+{ -+ 0, -+ v7_dma_inv_range, -+ v7_dma_clean_range, -+ v7_dma_flush_range, -+}; -+#elif defined(CONFIG_CPU_CACHE_V6) -+extern cache_flush_op_fn v6_dma_inv_range; -+extern cache_flush_op_fn v6_dma_clean_range; -+static cache_flush_op_fn * const flushops[4] = -+{ -+ 0, -+ v6_dma_inv_range, -+ v6_dma_clean_range, -+ v6_dma_flush_range, -+}; -+#else -+#error Unknown cache config -+#endif -+ - /* ---- Private Function Prototypes -------------------------------------- */ - - /* ---- Private Functions ------------------------------------------------ */ -@@ -2984,7 +3010,7 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - ret = -EFAULT; - goto out; - } -- block = kcalloc(ioparam.op_count, -+ block = kmalloc(ioparam.op_count * - sizeof(struct vmcs_sm_ioctl_clean_invalid_block), - GFP_KERNEL); - if (!block) { -@@ -3000,35 +3026,21 @@ static long vc_sm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) - } - - for (i = 0; i < ioparam.op_count; i++) { -- struct vmcs_sm_ioctl_clean_invalid_block *op = block + i; -+ const struct vmcs_sm_ioctl_clean_invalid_block * const op = block + i; -+ cache_flush_op_fn * const op_fn = flushops[op->invalidate_mode & 3]; - -- for (j = 0; j < op->block_count; ++j) { -+ if ((op->invalidate_mode & ~3) != 0) { -+ ret = -EINVAL; -+ break; -+ } - -+ if (op_fn == 0) -+ continue; - -- extern void v6_dma_inv_range(void *start, void *end); -- extern void v6_dma_clean_range(void *start, void *end); -- unsigned long base = (unsigned long)op->start_address + j * op->inter_block_stride; -- unsigned long end = base + op->block_size; -- /* L1/L2 cache clean */ -- if (op->invalidate_mode & 2) { --#if defined(CONFIG_CPU_CACHE_V7) -- extern void v7_dma_clean_range(void *start, void *end); -- v7_dma_clean_range((void *)base, (void *)end); --#elif defined(CONFIG_CPU_CACHE_V6) -- extern void v6_dma_clean_range(void *start, void *end); -- v6_dma_clean_range((void *)base, (void *)end); --#endif -- /* L1/L2 cache invalidate */ -- } -- if (op->invalidate_mode & 1) { --#if defined(CONFIG_CPU_CACHE_V7) -- extern void v7_dma_inv_range(void *start, void *end); -- v7_dma_inv_range((void *)base, (void *)end); --#elif defined(CONFIG_CPU_CACHE_V6) -- extern void v6_dma_inv_range(void *start, void *end); -- v6_dma_inv_range((void *)base, (void *)end); --#endif -- } -+ for (j = 0; j < op->block_count; ++j) { -+ const char * const base = (const char *)op->start_address + j * op->inter_block_stride; -+ const char * const end = base + op->block_size; -+ op_fn(base, end); - } - } - kfree(block);