Re: [PATCH 08/15] ARM/arm64: sunxi: Move H3/H5 syscon label over to soc-specific nodes
On Thu, Nov 15, 2018 at 03:50:06PM +0100, Paul Kocialkowski wrote: > Now that we have specific nodes for the H3 and H5 system-controller > that allow proper access to the EMAC clock configuration register, > we no longer need a common dummy syscon node. > > Switch the syscon label over to each platform's dtsi file. > > Signed-off-by: Paul Kocialkowski > --- > arch/arm/boot/dts/sun8i-h3.dtsi | 2 +- > arch/arm/boot/dts/sunxi-h3-h5.dtsi | 6 -- > arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 2 +- > 3 files changed, 2 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi > index 7157d954fb8c..b337a9282783 100644 > --- a/arch/arm/boot/dts/sun8i-h3.dtsi > +++ b/arch/arm/boot/dts/sun8i-h3.dtsi > @@ -134,7 +134,7 @@ > }; > > soc { > - system-control@1c0 { > + syscon: system-control@1c0 { > compatible = "allwinner,sun8i-h3-system-control"; > reg = <0x01c0 0x1000>; > #address-cells = <1>; > diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi > b/arch/arm/boot/dts/sunxi-h3-h5.dtsi > index 4b1530ebe427..9175ff0fb59a 100644 > --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi > +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi > @@ -152,12 +152,6 @@ > }; > }; > > - syscon: syscon@1c0 { > - compatible = "allwinner,sun8i-h3-system-controller", > - "syscon"; > - reg = <0x01c0 0x1000>; > - }; > - You're also dropping the syscon compatible there. But I'm not sure how it could work with the H3 EMAC driver that would overwrite the compatible already. Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 15/15] arm64: dts: allwinner: a64: Add Video Engine and reserved memory node
On Thu, Nov 15, 2018 at 03:50:13PM +0100, Paul Kocialkowski wrote: > This adds nodes for the Video Engine and the associated reserved memory > for the A64. Up to 96 MiB of memory are dedicated to the CMA pool. > > The pool is located at the end of the first 256 MiB of RAM so that the > VPU can access it. It is unclear whether this is still a hard > requirement for this platform, but it seems safer that way. > > Signed-off-by: Paul Kocialkowski > --- > arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 25 +++ > 1 file changed, 25 insertions(+) > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi > b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi > index 88b3e9110833..a35a5c9ffbbe 100644 > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi > @@ -185,6 +185,20 @@ > (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; > }; > > + reserved-memory { > + #address-cells = <1>; > + #size-cells = <1>; > + ranges; > + > + cma_pool: cma@4a00 { > + compatible = "shared-dma-pool"; > + size = <0x600>; > + alloc-ranges = <0x4a00 0x600>; This introduces a DTC warning, since you're using a unit-address, but don't have a reg register. I've fixed it in the other DT by renaming that node to default-pool. You can also drop the label, it's not used anywhere. Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 08/15] ARM/arm64: sunxi: Move H3/H5 syscon label over to soc-specific nodes
On Fri, Nov 16, 2018 at 5:39 PM Maxime Ripard wrote: > > On Thu, Nov 15, 2018 at 03:50:06PM +0100, Paul Kocialkowski wrote: > > Now that we have specific nodes for the H3 and H5 system-controller > > that allow proper access to the EMAC clock configuration register, > > we no longer need a common dummy syscon node. > > > > Switch the syscon label over to each platform's dtsi file. > > > > Signed-off-by: Paul Kocialkowski > > --- > > arch/arm/boot/dts/sun8i-h3.dtsi | 2 +- > > arch/arm/boot/dts/sunxi-h3-h5.dtsi | 6 -- > > arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 2 +- > > 3 files changed, 2 insertions(+), 8 deletions(-) > > > > diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi > > b/arch/arm/boot/dts/sun8i-h3.dtsi > > index 7157d954fb8c..b337a9282783 100644 > > --- a/arch/arm/boot/dts/sun8i-h3.dtsi > > +++ b/arch/arm/boot/dts/sun8i-h3.dtsi > > @@ -134,7 +134,7 @@ > > }; > > > > soc { > > - system-control@1c0 { > > + syscon: system-control@1c0 { > > compatible = "allwinner,sun8i-h3-system-control"; > > reg = <0x01c0 0x1000>; > > #address-cells = <1>; > > diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > b/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > index 4b1530ebe427..9175ff0fb59a 100644 > > --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > @@ -152,12 +152,6 @@ > > }; > > }; > > > > - syscon: syscon@1c0 { > > - compatible = "allwinner,sun8i-h3-system-controller", > > - "syscon"; > > - reg = <0x01c0 0x1000>; > > - }; > > - > > You're also dropping the syscon compatible there. But I'm not sure how > it could work with the H3 EMAC driver that would overwrite the > compatible already. I assume you are referring to the previous patch? The node names are not the same, hence the previous patch is adding another node for the system controller, and this patch removes the old one with the "syscon" compatible. We already patched the EMAC driver to support the new SRAM controller based regmap, so other than making people unhappy about having to update their DT, I don't think there would be any problems. This also means H3 in -next currently has _two_ syscon nodes. ChenYu ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 08/15] ARM/arm64: sunxi: Move H3/H5 syscon label over to soc-specific nodes
Hi, Le vendredi 16 novembre 2018 à 17:47 +0800, Chen-Yu Tsai a écrit : > On Fri, Nov 16, 2018 at 5:39 PM Maxime Ripard > wrote: > > On Thu, Nov 15, 2018 at 03:50:06PM +0100, Paul Kocialkowski wrote: > > > Now that we have specific nodes for the H3 and H5 system-controller > > > that allow proper access to the EMAC clock configuration register, > > > we no longer need a common dummy syscon node. > > > > > > Switch the syscon label over to each platform's dtsi file. > > > > > > Signed-off-by: Paul Kocialkowski > > > --- > > > arch/arm/boot/dts/sun8i-h3.dtsi | 2 +- > > > arch/arm/boot/dts/sunxi-h3-h5.dtsi | 6 -- > > > arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 2 +- > > > 3 files changed, 2 insertions(+), 8 deletions(-) > > > > > > diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi > > > b/arch/arm/boot/dts/sun8i-h3.dtsi > > > index 7157d954fb8c..b337a9282783 100644 > > > --- a/arch/arm/boot/dts/sun8i-h3.dtsi > > > +++ b/arch/arm/boot/dts/sun8i-h3.dtsi > > > @@ -134,7 +134,7 @@ > > > }; > > > > > > soc { > > > - system-control@1c0 { > > > + syscon: system-control@1c0 { > > > compatible = "allwinner,sun8i-h3-system-control"; > > > reg = <0x01c0 0x1000>; > > > #address-cells = <1>; > > > diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > > b/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > > index 4b1530ebe427..9175ff0fb59a 100644 > > > --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > > +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > > @@ -152,12 +152,6 @@ > > > }; > > > }; > > > > > > - syscon: syscon@1c0 { > > > - compatible = "allwinner,sun8i-h3-system-controller", > > > - "syscon"; > > > - reg = <0x01c0 0x1000>; > > > - }; > > > - > > > > You're also dropping the syscon compatible there. But I'm not sure how > > it could work with the H3 EMAC driver that would overwrite the > > compatible already. > > I assume you are referring to the previous patch? The node names are not > the same, hence the previous patch is adding another node for the system > controller, and this patch removes the old one with the "syscon" compatible. > > We already patched the EMAC driver to support the new SRAM controller based > regmap, so other than making people unhappy about having to update their > DT, I don't think there would be any problems. This also means H3 in -next > currently has _two_ syscon nodes. Yes, the point is indeed to only have a single node per platform (in the platform dtsi) instead of two (one in the common h3-h5 dtsi and one in the platform dtsi). I guess updating the dt is not even a hard requirement after this series: things will keep working with the dummy syscon node for giving the EMAC driver access to the syscon registers. Cheers, Paul ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 01/15] ARM: dts: sun8i-a33: Remove heading 0 in video-codec unit address
Hi, Le jeudi 15 novembre 2018 à 23:50 +0800, Chen-Yu Tsai a écrit : > On Thu, Nov 15, 2018 at 10:50 PM Paul Kocialkowski > wrote: > > This cosmetic change removes the heading 0 in the video-codec unit > > address, as it's done for other nodes. > > > > Signed-off-by: Paul Kocialkowski > > Nit: I'd prefer the subject prefix format be ": : ... ", > or "sun8i: a33:" in this case. This format seems to be used more often > than your alternative format. > > I can fix it up when applying. Understood, I will make sure to follow this convention next time. Cheers, Paul > Acked-by: Chen-Yu Tsai > > ChenYu ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] media: cedrus: Remove global IRQ spin lock from the driver
On Thu, Nov 15, 2018 at 03:39:55PM +0100, Paul Kocialkowski wrote: > We initially introduced a spin lock to ensure that the VPU registers > are not accessed concurrently between our setup function and IRQ > handler. Because the V4L2 M2M API only allows one job to run at a time > and our jobs are completed following the IRQ handler, there is actually > no chance of an interrupt happening while programming the VPU registers. That's not entirely true. There's no chance that the interrupt signaling the end of the frame decoding can happen. However, spurious interrupts can happen at any point in time as soon as you have the interrupts enabled. > In addition, holding a spin lock is problematic when doing more than > simply configuring the registers in the setup operation. H.265 support > currently involves a CMA allocation in that step, which is not > compatible with an atomic context. That's not really true either. Any allocation can be done with GFP_ATOMIC or GFP_NOWAIT, and be compatible with an atomic context. Whether it's something we want is a different story :) And since the h265 code isn't upstream, I'm not really sure it's relevant to mention it here. > As a result, remove the global IRQ spin lock. > > Signed-off-by: Paul Kocialkowski Acked-by: Maxime Ripard Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: RFC: staging: gasket: re-implement using UIO
Hi Todd, On Tue, Nov 06, 2018 at 04:20:49PM -0800, Todd Poynor wrote: > On Mon, Sep 10, 2018 at 8:28 AM Ahmed S. Darwish wrote: > > > > The gasket in-kernel framework, recently introduced under staging, > > re-implements what is already long-time provided by the UIO > > subsystem, with extra PCI BAR remapping and MSI conveniences. > > > > Before moving it out of staging, make sure we add the new bits to > > the UIO framework instead, then transform its signle client, the > > Apex driver, to a proper UIO driver (uio_driver.h). > > > > Link: https://lkml.kernel.org/r/20180828103817.GB1397@do-kernel > > So I'm looking at this for reals now. The BAR mapping stuff is > straightforward with the existing framework. Everything else could be > done outside of UIO via the existing device interface, but figured I'd > collect any opinions about adding the new bits to UIO. > If it won't slow you down, I'd actually be more than happy to get involved in adding the necessary bits to UIO. Thanks! -- Darwi http://darwish.chasingpointers.com ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: greybus: arche-platform: Switch to the gpio descriptor interface
Use the gpiod interface instead of the deprecated old non-descriptor interface. Signed-off-by: Nishad Kamdar --- drivers/staging/greybus/arche-platform.c | 120 --- 1 file changed, 42 insertions(+), 78 deletions(-) diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c index 4c36e88766e7..a826a1835628 100644 --- a/drivers/staging/greybus/arche-platform.c +++ b/drivers/staging/greybus/arche-platform.c @@ -8,10 +8,9 @@ #include #include -#include +#include #include #include -#include #include #include #include @@ -45,14 +44,15 @@ enum svc_wakedetect_state { struct arche_platform_drvdata { /* Control GPIO signals to and from AP <=> SVC */ - int svc_reset_gpio; + struct gpio_desc *svc_reset; + struct gpio_desc *svc_sysboot; bool is_reset_act_hi; - int svc_sysboot_gpio; - int wake_detect_gpio; /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */ + struct gpio_desc *wake_detect; + /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */ enum arche_platform_state state; - int svc_refclk_req; + struct gpio_desc *svc_refclk_req; struct clk *svc_ref_clk; struct pinctrl *pinctrl; @@ -85,9 +85,9 @@ static void arche_platform_set_wake_detect_state( arche_pdata->wake_detect_state = state; } -static inline void svc_reset_onoff(unsigned int gpio, bool onoff) +static inline void svc_reset_onoff(struct gpio_desc *gpio, bool onoff) { - gpio_set_value(gpio, onoff); + gpiod_set_value(gpio, onoff); } static int apb_cold_boot(struct device *dev, void *data) @@ -116,7 +116,6 @@ static int apb_poweroff(struct device *dev, void *data) static void arche_platform_wd_irq_en(struct arche_platform_drvdata *arche_pdata) { /* Enable interrupt here, to read event back from SVC */ - gpio_direction_input(arche_pdata->wake_detect_gpio); enable_irq(arche_pdata->wake_detect_irq); } @@ -160,7 +159,7 @@ static irqreturn_t arche_platform_wd_irq(int irq, void *devid) spin_lock_irqsave(&arche_pdata->wake_lock, flags); - if (gpio_get_value(arche_pdata->wake_detect_gpio)) { + if (gpiod_get_value(arche_pdata->wake_detect)) { /* wake/detect rising */ /* @@ -224,10 +223,10 @@ arche_platform_coldboot_seq(struct arche_platform_drvdata *arche_pdata) dev_info(arche_pdata->dev, "Booting from cold boot state\n"); - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, arche_pdata->is_reset_act_hi); - gpio_set_value(arche_pdata->svc_sysboot_gpio, 0); + gpiod_set_value(arche_pdata->svc_sysboot, 0); usleep_range(100, 200); ret = clk_prepare_enable(arche_pdata->svc_ref_clk); @@ -238,7 +237,7 @@ arche_platform_coldboot_seq(struct arche_platform_drvdata *arche_pdata) } /* bring SVC out of reset */ - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, !arche_pdata->is_reset_act_hi); arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_ACTIVE); @@ -259,10 +258,10 @@ arche_platform_fw_flashing_seq(struct arche_platform_drvdata *arche_pdata) dev_info(arche_pdata->dev, "Switching to FW flashing state\n"); - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, arche_pdata->is_reset_act_hi); - gpio_set_value(arche_pdata->svc_sysboot_gpio, 1); + gpiod_set_value(arche_pdata->svc_sysboot, 1); usleep_range(100, 200); @@ -273,7 +272,7 @@ arche_platform_fw_flashing_seq(struct arche_platform_drvdata *arche_pdata) return ret; } - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, !arche_pdata->is_reset_act_hi); arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_FW_FLASHING); @@ -305,7 +304,7 @@ arche_platform_poweroff_seq(struct arche_platform_drvdata *arche_pdata) clk_disable_unprepare(arche_pdata->svc_ref_clk); /* As part of exit, put APB back in reset state */ - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, arche_pdata->is_reset_act_hi); arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_OFF); @@ -435,6 +434,7 @@ static int arche_platform_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; int ret; + unsigned int flags; arche_pdata = devm_kzalloc(&pdev->dev, sizeof(*arche_pdata), GFP_KERNEL); @@ -444,61 +444,33 @@ static int arche_platform_probe(struct platform_device *pdev) /* setup svc reset gpio *
Re: [PATCH] staging: greybus: arche-platform: Switch to the gpio descriptor interface
On Fri, Nov 16, 2018 at 08:47:44PM +0530, Nishad Kamdar wrote: > Use the gpiod interface instead of the deprecated > old non-descriptor interface. > > Signed-off-by: Nishad Kamdar > --- Always include a change log here after the cut-off line so we know what changed since previous versions. Also include the patch revision in the Subject (e.g. "[PATCH v3] staging: greybus: ..."). > drivers/staging/greybus/arche-platform.c | 120 --- > 1 file changed, 42 insertions(+), 78 deletions(-) > > diff --git a/drivers/staging/greybus/arche-platform.c > b/drivers/staging/greybus/arche-platform.c > index 4c36e88766e7..a826a1835628 100644 > --- a/drivers/staging/greybus/arche-platform.c > +++ b/drivers/staging/greybus/arche-platform.c > @@ -8,10 +8,9 @@ > > #include > #include > -#include > +#include > #include > #include > -#include > #include > #include > #include > @@ -45,14 +44,15 @@ enum svc_wakedetect_state { > > struct arche_platform_drvdata { > /* Control GPIO signals to and from AP <=> SVC */ > - int svc_reset_gpio; > + struct gpio_desc *svc_reset; > + struct gpio_desc *svc_sysboot; > bool is_reset_act_hi; > - int svc_sysboot_gpio; > - int wake_detect_gpio; /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */ > + struct gpio_desc *wake_detect; > + /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */ I'm not commenting on the rest, but comments never go underneath what they apply to. Just keep the current comment here, even if it's placement is a bit odd and makes the line be longer than 80 cols. Johan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 01/17] power: supply: olpc_battery: correct the temperature units
According to [1] and [2], the temperature values are in tenths of degree Celsius. Exposing the Celsius value makes the battery appear on fire: $ upower -i /org/freedesktop/UPower/devices/battery_olpc_battery ... temperature: 236.9 degrees C Tested on OLPC XO-1 and OLPC XO-1.75 laptops. [1] include/linux/power_supply.h [2] Documentation/power/power_supply_class.txt Fixes: fb972873a767 ("[BATTERY] One Laptop Per Child power/battery driver") Cc: sta...@vger.kernel.org Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - Add Fixes tag and an Ack drivers/power/supply/olpc_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index 6da79ae14860..5a97e42a3547 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -428,14 +428,14 @@ static int olpc_bat_get_property(struct power_supply *psy, if (ret) return ret; - val->intval = (s16)be16_to_cpu(ec_word) * 100 / 256; + val->intval = (s16)be16_to_cpu(ec_word) * 10 / 256; break; case POWER_SUPPLY_PROP_TEMP_AMBIENT: ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2); if (ret) return ret; - val->intval = (int)be16_to_cpu(ec_word) * 100 / 256; + val->intval = (int)be16_to_cpu(ec_word) * 10 / 256; break; case POWER_SUPPLY_PROP_CHARGE_COUNTER: ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2); -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 10/17] Platform: OLPC: add a regulator for the DCON
All OLPC ECs are able to turn the power to the DCON on an off. Use the regulator framework to expose the functionality. Signed-off-by: Lubomir Rintel --- Changes since v1: - Use idiomatic form of return on error - Avoid mixing bool and int drivers/platform/olpc/Kconfig | 1 + drivers/platform/olpc/olpc-ec.c | 67 + 2 files changed, 68 insertions(+) diff --git a/drivers/platform/olpc/Kconfig b/drivers/platform/olpc/Kconfig index 7c643d24ad0f..c5a872fb286f 100644 --- a/drivers/platform/olpc/Kconfig +++ b/drivers/platform/olpc/Kconfig @@ -6,6 +6,7 @@ config OLPC select OF select OF_PROMTREE if X86 select IRQ_DOMAIN + select REGULATOR help Add support for detecting the unique features of the OLPC XO hardware. diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c index 2b80174b8f4b..f725ab2a2db9 100644 --- a/drivers/platform/olpc/olpc-ec.c +++ b/drivers/platform/olpc/olpc-ec.c @@ -14,6 +14,7 @@ #include #include #include +#include #include struct ec_cmd_desc { @@ -34,6 +35,10 @@ struct olpc_ec_priv { struct work_struct worker; struct mutex cmd_lock; + /* DCON regulator */ + struct regulator_dev *dcon_rdev; + bool dcon_enabled; + /* Pending EC commands */ struct list_head cmd_q; spinlock_t cmd_q_lock; @@ -344,9 +349,61 @@ static struct dentry *olpc_ec_setup_debugfs(void) #endif /* CONFIG_DEBUG_FS */ +static int olpc_ec_set_dcon_power(struct olpc_ec_priv *ec, bool state) +{ + unsigned char ec_byte = state; + int ret; + + if (ec->dcon_enabled == state) + return 0; + + ret = olpc_ec_cmd(EC_DCON_POWER_MODE, &ec_byte, 1, NULL, 0); + if (ret) + return ret; + + ec->dcon_enabled = state; + return 0; +} + +static int dcon_regulator_enable(struct regulator_dev *rdev) +{ + struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); + + return olpc_ec_set_dcon_power(ec, true); +} + +static int dcon_regulator_disable(struct regulator_dev *rdev) +{ + struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); + + return olpc_ec_set_dcon_power(ec, false); +} + +static int dcon_regulator_is_enabled(struct regulator_dev *rdev) +{ + struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); + + return ec->dcon_enabled ? 1 : 0; +} + +static struct regulator_ops dcon_regulator_ops = { + .enable = dcon_regulator_enable, + .disable= dcon_regulator_disable, + .is_enabled = dcon_regulator_is_enabled, +}; + +static const struct regulator_desc dcon_desc = { + .name = "dcon", + .id = 0, + .ops= &dcon_regulator_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, +}; + static int olpc_ec_probe(struct platform_device *pdev) { struct olpc_ec_priv *ec; + struct regulator_config config = { }; int err; if (!ec_driver) @@ -374,6 +431,16 @@ static int olpc_ec_probe(struct platform_device *pdev) return err; } + config.dev = pdev->dev.parent; + config.driver_data = ec; + ec->dcon_enabled = true; + ec->dcon_rdev = devm_regulator_register(&pdev->dev, &dcon_desc, + &config); + if (IS_ERR(ec->dcon_rdev)) { + dev_err(&pdev->dev, "failed to register DCON regulator\n"); + return PTR_ERR(ec->dcon_rdev); + } + ec->dbgfs_dir = olpc_ec_setup_debugfs(); return err; -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 13/17] power: supply: olpc_battery: Use DT to get battery version
Avoid using the x86 OLPC platform specific call to get the board version. It won't work on FDT-based ARM MMP2 platform. Signed-off-by: Lubomir Rintel Reviewed-by: Andy Shevchenko Acked-by: Pavel Machek --- Changes since v1: - Sort the new include a bit higher drivers/power/supply/olpc_battery.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index 5a97e42a3547..5323987d9284 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -622,11 +623,13 @@ static int olpc_battery_probe(struct platform_device *pdev) olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, NULL); if (IS_ERR(olpc_ac)) return PTR_ERR(olpc_ac); - - if (olpc_board_at_least(olpc_board_pre(0xd0))) { /* XO-1.5 */ + if (of_property_match_string(pdev->dev.of_node, "compatible", + "olpc,xo1.5-battery") >= 0) { + /* XO-1.5 */ olpc_bat_desc.properties = olpc_xo15_bat_props; olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo15_bat_props); - } else { /* XO-1 */ + } else { + /* XO-1 */ olpc_bat_desc.properties = olpc_xo1_bat_props; olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props); } @@ -672,6 +675,7 @@ static int olpc_battery_remove(struct platform_device *pdev) static const struct of_device_id olpc_battery_ids[] = { { .compatible = "olpc,xo1-battery" }, + { .compatible = "olpc,xo1.5-battery" }, {} }; MODULE_DEVICE_TABLE(of, olpc_battery_ids); -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 0/17] Add support for OLPC XO 1.75 Embedded Controller
Hi everyone! This is a second spin of the patch set that adds support for the Embedded Controller on an OLPC XO 1.75 machine. OLPC XO 1.75 is a MMP2 based ARM laptop. It plugs into the existing OLPC platform infrastructure, currently used by the x86 based models. The slave mode support for MMP2's SPI controller that the EC is hooked to is now in spi.git's for-4.21 branch. The v1 received a fair number of comments. I've attempted to address all of them, either by fixing things or responding to the v1 review. See the change logs in the individual patches for details. If I've overlooked something then I apologize -- I haven't dealt with a patch set as big as this and I'm struggling to incorporate the feedback in an organized manner. Advice from the more experienced folks around here are welcome. Tested to work on an OLPC XO 1.75 and also tested not to break x86 support with an OLPC XO 1 machine. I don't have a XO 1.5, but it's unlikely this breaks it when XO 1 works. Lubo ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 15/17] power: supply: olpc_battery: Use devm_power_supply_register()
This simplifies the error handling. Signed-off-by: Lubomir Rintel --- Changes since v1: - This was split off the "power: supply: olpc_battery: Move priv data to a struct" patch. drivers/power/supply/olpc_battery.c | 19 +-- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index b091f897c1d4..4433eb10a23d 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -628,7 +628,7 @@ static int olpc_battery_probe(struct platform_device *pdev) psy_cfg.of_node = pdev->dev.of_node; psy_cfg.drv_data = data; - data->olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg); + data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg); if (IS_ERR(data->olpc_ac)) return PTR_ERR(data->olpc_ac); @@ -643,15 +643,13 @@ static int olpc_battery_probe(struct platform_device *pdev) olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props); } - data->olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg); - if (IS_ERR(olpc_bat)) { - ret = PTR_ERR(olpc_bat); - goto battery_failed; - } + data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg); + if (IS_ERR(data->olpc_bat)) + return PTR_ERR(data->olpc_bat); ret = device_create_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); if (ret) - goto eeprom_failed; + return ret; ret = device_create_file(&data->olpc_bat->dev, &olpc_bat_error); if (ret) @@ -666,10 +664,6 @@ static int olpc_battery_probe(struct platform_device *pdev) error_failed: device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); -eeprom_failed: - power_supply_unregister(data->olpc_bat); -battery_failed: - power_supply_unregister(data->olpc_ac); return ret; } @@ -679,9 +673,6 @@ static int olpc_battery_remove(struct platform_device *pdev) device_remove_file(&data->olpc_bat->dev, &olpc_bat_error); device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); - power_supply_unregister(data->olpc_bat); - power_supply_unregister(data->olpc_ac); - return 0; } -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 07/17] Platform: OLPC: Avoid a warning if the EC didn't register yet
Just return ENODEV, so that whoever attempted to use the EC call can defer their work. Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - EPROBE_DEFER instead of ENODEV drivers/platform/olpc/olpc-ec.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c index 35a21c66cd0d..9ee993d5d54b 100644 --- a/drivers/platform/olpc/olpc-ec.c +++ b/drivers/platform/olpc/olpc-ec.c @@ -116,8 +116,11 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen) struct olpc_ec_priv *ec = ec_priv; struct ec_cmd_desc desc; - /* Ensure a driver and ec hook have been registered */ - if (WARN_ON(!ec_driver || !ec_driver->ec_cmd)) + /* Driver not yet registered. */ + if (!ec_driver) + return -EPROBE_DEFER; + + if (WARN_ON(!ec_driver->ec_cmd)) return -ENODEV; if (!ec) -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 09/17] Platform: OLPC: Use BIT() and GENMASK() for event masks
Just a cosmetic tidy-up. Signed-off-by: Lubomir Rintel --- Changes since v1: - This patch was added to the set. include/linux/olpc-ec.h | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h index 7fa3d27f7fee..f7b6a7eda232 100644 --- a/include/linux/olpc-ec.h +++ b/include/linux/olpc-ec.h @@ -2,6 +2,8 @@ #ifndef _LINUX_OLPC_EC_H #define _LINUX_OLPC_EC_H +#include + /* XO-1 EC commands */ #define EC_FIRMWARE_REV0x08 #define EC_WRITE_SCI_MASK 0x1b @@ -17,17 +19,16 @@ #define EC_EXT_SCI_QUERY 0x85 /* SCI source values */ -#define EC_SCI_SRC_EMPTY0x00 -#define EC_SCI_SRC_GAME 0x01 -#define EC_SCI_SRC_BATTERY 0x02 -#define EC_SCI_SRC_BATSOC 0x04 -#define EC_SCI_SRC_BATERR 0x08 -#define EC_SCI_SRC_EBOOK0x10/* XO-1 only */ -#define EC_SCI_SRC_WLAN 0x20/* XO-1 only */ -#define EC_SCI_SRC_ACPWR0x40 -#define EC_SCI_SRC_BATCRIT 0x80 -#define EC_SCI_SRC_GPWAKE 0x100 /* XO-1.5 only */ -#define EC_SCI_SRC_ALL 0x1FF +#define EC_SCI_SRC_GAME BIT(0) +#define EC_SCI_SRC_BATTERY BIT(1) +#define EC_SCI_SRC_BATSOC BIT(2) +#define EC_SCI_SRC_BATERR BIT(3) +#define EC_SCI_SRC_EBOOKBIT(4)/* XO-1 only */ +#define EC_SCI_SRC_WLAN BIT(5)/* XO-1 only */ +#define EC_SCI_SRC_ACPWRBIT(6) +#define EC_SCI_SRC_BATCRIT BIT(7) +#define EC_SCI_SRC_GPWAKE BIT(8) /* XO-1.5 only */ +#define EC_SCI_SRC_ALL GENMASK(8, 0) struct platform_device; -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 05/17] Platform: OLPC: Move OLPC config symbol out of x86 tree
There are ARM OLPC machines that use mostly the same drivers, including EC infrastructure, DCON and Battery. While at that, fix Kconfig to allow building this as a module. Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - Use 'depends on OLPC && X86' idiom (thanks Andy Shevchenko) arch/x86/Kconfig | 11 --- drivers/input/mouse/Kconfig | 3 ++- drivers/platform/Kconfig | 2 ++ drivers/platform/olpc/Kconfig | 11 +++ drivers/staging/olpc_dcon/Kconfig | 3 ++- 5 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 drivers/platform/olpc/Kconfig diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 9d734f3c8234..f98f78e317d4 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2734,17 +2734,6 @@ config SCx200HR_TIMER processor goes idle (as is done by the scheduler). The other workaround is idle=poll boot option. -config OLPC - bool "One Laptop Per Child support" - depends on !X86_PAE - select GPIOLIB - select OF - select OF_PROMTREE - select IRQ_DOMAIN - ---help--- - Add support for detecting the unique features of the OLPC - XO hardware. - config OLPC_XO1_PM bool "OLPC XO-1 Power Management" depends on OLPC && MFD_CS5535=y && PM_SLEEP diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig index 566a1e3aa504..cf12d0e4fba2 100644 --- a/drivers/input/mouse/Kconfig +++ b/drivers/input/mouse/Kconfig @@ -165,7 +165,8 @@ config MOUSE_PS2_TOUCHKIT config MOUSE_PS2_OLPC bool "OLPC PS/2 mouse protocol extension" - depends on MOUSE_PS2 && OLPC + depends on MOUSE_PS2 + depends on OLPC && X86 help Say Y here if you have an OLPC XO-1 laptop (with built-in PS/2 touchpad/tablet device). The manufacturer calls the diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig index d4c2e424a700..4313d73d3618 100644 --- a/drivers/platform/Kconfig +++ b/drivers/platform/Kconfig @@ -10,3 +10,5 @@ source "drivers/platform/goldfish/Kconfig" source "drivers/platform/chrome/Kconfig" source "drivers/platform/mellanox/Kconfig" + +source "drivers/platform/olpc/Kconfig" diff --git a/drivers/platform/olpc/Kconfig b/drivers/platform/olpc/Kconfig new file mode 100644 index ..7b736c9e67ac --- /dev/null +++ b/drivers/platform/olpc/Kconfig @@ -0,0 +1,11 @@ +config OLPC + tristate "One Laptop Per Child support" + depends on X86 || ARM || COMPILE_TEST + depends on !X86_PAE + select GPIOLIB + select OF + select OF_PROMTREE if X86 + select IRQ_DOMAIN + help + Add support for detecting the unique features of the OLPC + XO hardware. diff --git a/drivers/staging/olpc_dcon/Kconfig b/drivers/staging/olpc_dcon/Kconfig index 192cc8d0853f..ff540350f50f 100644 --- a/drivers/staging/olpc_dcon/Kconfig +++ b/drivers/staging/olpc_dcon/Kconfig @@ -1,8 +1,9 @@ config FB_OLPC_DCON tristate "One Laptop Per Child Display CONtroller support" - depends on OLPC && FB + depends on FB depends on I2C depends on BACKLIGHT_LCD_SUPPORT + depends on OLPC && X86 depends on (GPIO_CS5535 || GPIO_CS5535=n) select BACKLIGHT_CLASS_DEVICE help -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 02/17] dt-bindings: olpc, xo1.75-ec: Add OLPC XO-1.75 EC bindings
The OLPC XO-1.75 Embedded Controller is a SPI master that uses extra signals for handshaking. It needs to know when is the slave (Linux) side's TX FIFO ready for transfer (the ready-gpio signal on the SPI controller node) and when does it wish to respond with a command (the cmd-gpio property). Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - s/cmd-gpio/cmd-gpios/ - s/ready-gpio/ready-gpios/ in the documentation paragraph - Remove status = "okay" from the example .../bindings/misc/olpc,xo1.75-ec.txt | 23 +++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/olpc,xo1.75-ec.txt diff --git a/Documentation/devicetree/bindings/misc/olpc,xo1.75-ec.txt b/Documentation/devicetree/bindings/misc/olpc,xo1.75-ec.txt new file mode 100644 index ..8c4d649cdd8f --- /dev/null +++ b/Documentation/devicetree/bindings/misc/olpc,xo1.75-ec.txt @@ -0,0 +1,23 @@ +OLPC XO-1.75 Embedded Controller + +Required properties: +- compatible: Should be "olpc,xo1.75-ec". +- cmd-gpios: gpio specifier of the CMD pin + +The embedded controller requires the SPI controller driver to signal readiness +to receive a transfer (that is, when TX FIFO contains the response data) by +strobing the ACK pin with the ready signal. See the "ready-gpios" property of the +SSP binding as documented in: +. + +Example: + &ssp3 { + spi-slave; + ready-gpios = <&gpio 125 GPIO_ACTIVE_HIGH>; + + slave { + compatible = "olpc,xo1.75-ec"; + spi-cpha; + cmd-gpios = <&gpio 155 GPIO_ACTIVE_HIGH>; + }; + }; -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 03/17] Platform: OLPC: Remove an unused include
Also, the header is x86 specific, while there are non-x86 OLPC machines. Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- drivers/platform/olpc/olpc-ec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c index 374a8028fec7..981955dce926 100644 --- a/drivers/platform/olpc/olpc-ec.c +++ b/drivers/platform/olpc/olpc-ec.c @@ -17,7 +17,6 @@ #include #include #include -#include struct ec_cmd_desc { u8 cmd; -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 04/17] Revert "platform/olpc: Make ec explicitly non-modular"
It doesn't make sense to always have this built-in, e.g. on ARM multiplatform kernels. A better way to address the problem the original commit aimed to solve is to fix Kconfig. That is what the next commit in the series does. This reverts commit f48d1496b8537d75776478c6942dd87f34d7f270. Signed-off-by: Lubomir Rintel --- Changes since v1: - Sort it later in the patch set drivers/platform/olpc/olpc-ec.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c index 981955dce926..35a21c66cd0d 100644 --- a/drivers/platform/olpc/olpc-ec.c +++ b/drivers/platform/olpc/olpc-ec.c @@ -1,8 +1,6 @@ /* * Generic driver for the OLPC Embedded Controller. * - * Author: Andres Salomon - * * Copyright (C) 2011-2012 One Laptop per Child Foundation. * * Licensed under the GPL v2 or later. @@ -14,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -327,4 +325,8 @@ static int __init olpc_ec_init_module(void) { return platform_driver_register(&olpc_ec_plat_driver); } + arch_initcall(olpc_ec_init_module); + +MODULE_AUTHOR("Andres Salomon "); +MODULE_LICENSE("GPL"); -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 12/17] x86, olpc: Use a correct version when making up a battery node
The XO-1 and XO-1.5 batteries apparently differ in an ability to report ambient temperature. Add a different compatible string to the 1.5 battery. Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - Avoid splitting string literals arch/x86/platform/olpc/olpc_dt.c | 85 +--- 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c index 24d2175a9480..6063f52ed807 100644 --- a/arch/x86/platform/olpc/olpc_dt.c +++ b/arch/x86/platform/olpc/olpc_dt.c @@ -218,10 +218,28 @@ static u32 __init olpc_dt_get_board_revision(void) return be32_to_cpu(rev); } -void __init olpc_dt_fixup(void) +int olpc_dt_compatible_match(phandle node, const char *compat) { - int r; char buf[64]; + int plen; + char *p; + int len; + + plen = olpc_dt_getproperty(node, "compatible", buf, sizeof(buf)); + if (plen <= 0) + return 0; + + len = strlen(compat); + for (p = buf; p < buf + plen; p += strlen(p) + 1) { + if (strcmp(p, compat) == 0) + return 1; + } + + return 0; +} + +void __init olpc_dt_fixup(void) +{ phandle node; u32 board_rev; @@ -229,41 +247,51 @@ void __init olpc_dt_fixup(void) if (!node) return; - /* -* If the battery node has a compatible property, we are running a new -* enough firmware and don't have fixups to make. -*/ - r = olpc_dt_getproperty(node, "compatible", buf, sizeof(buf)); - if (r > 0) - return; - - pr_info("PROM DT: Old firmware detected, applying fixes\n"); - - /* Add olpc,xo1-battery compatible marker to battery node */ - olpc_dt_interpret("\" /battery@0\" find-device" - " \" olpc,xo1-battery\" +compatible" - " device-end"); - board_rev = olpc_dt_get_board_revision(); if (!board_rev) return; if (board_rev >= olpc_board_pre(0xd0)) { + if (olpc_dt_compatible_match(node, "olpc,xo1.5-battery")) + return; + + /* Add olpc,xo1.5-battery compatible marker to battery node */ + olpc_dt_interpret("\" /battery@0\" find-device"); + olpc_dt_interpret(" \" olpc,xo1.5-battery\" +compatible"); + olpc_dt_interpret("device-end"); + + /* We're running a very old firmware if this is missing. */ + if (olpc_dt_compatible_match(node, "olpc,xo1-battery")) + return; + /* XO-1.5: add dcon device */ - olpc_dt_interpret("\" /pci/display@1\" find-device" - " new-device" - " \" dcon\" device-name \" olpc,xo1-dcon\" +compatible" - " finish-device device-end"); + olpc_dt_interpret("\" /pci/display@1\" find-device"); + olpc_dt_interpret(" new-device"); + olpc_dt_interpret("\" dcon\" device-name"); + olpc_dt_interpret("\" olpc,xo1-dcon\" +compatible"); + olpc_dt_interpret(" finish-device"); + olpc_dt_interpret("device-end"); } else { + /* We're running a very old firmware if this is missing. */ + if (olpc_dt_compatible_match(node, "olpc,xo1-battery")) + return; + /* XO-1: add dcon device, mark RTC as olpc,xo1-rtc */ - olpc_dt_interpret("\" /pci/display@1,1\" find-device" - " new-device" - " \" dcon\" device-name \" olpc,xo1-dcon\" +compatible" - " finish-device device-end" - " \" /rtc\" find-device" - " \" olpc,xo1-rtc\" +compatible" - " device-end"); + olpc_dt_interpret("\" /pci/display@1,1\" find-device"); + olpc_dt_interpret(" new-device"); + olpc_dt_interpret("\" dcon\" device-name"); + olpc_dt_interpret("\" olpc,xo1-dcon\" +compatible"); + olpc_dt_interpret(" finish-device"); + olpc_dt_interpret("device-end"); + olpc_dt_interpret("\" /rtc\" find-device"); + olpc_dt_interpret(" \" olpc,xo1-rtc\" +compatible"); + olpc_dt_interpret("device-end"); } + + /* Add olpc,xo1-battery compatible marker to battery node */ + olpc_dt_interpret("\" /battery@0\" find-device"); + olpc_dt_interpret(" \" olpc,xo1-battery\" +compatible"); + olpc_dt_interpret("device-end"); } void __init olpc_dt_build_devicetree(void) @@ -289,6 +317,7 @@ void __init olpc_dt_build_devicetree(void) /* A list of DT node/bus matches that we want to expose as platform devices */ static struct of_device_id __initdata of_ids[] = {
[PATCH v2 06/17] Platform: OLPC: Add XO-1.75 EC driver
It's based off the driver from the OLPC kernel sources. Somewhat modernized and cleaned up, for better or worse. Modified to plug into the olpc-ec driver infrastructure (so that battery interface and debugfs could be reused) and the SPI slave framework. Signed-off-by: Lubomir Rintel --- Changes since v1: - Cosmetic style changes; whitespace, ordering of declarations and #includes, remoted extra comas from sentinels - Count the terminating NUL in LOG_BUF_SIZE - Make olpc_xo175_ec_is_valid_cmd() return -EINVAL instead of -1 on error - Spell keyboard/touchpad in full for CHAN_KEYBOARD/TOUCHPAD messages - Use a #define for PM wakeup processing time - Log a message on unknown event - Escape logging payload with %*pE - Replace an open-coded min() - Correct an error code on short read - replaced PM callback #ifdefs with __maybe_unusedm SET_RUNTIME_PM_OPS and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS - dev_get_drvdata() instead of a round-trip through platform device - s/unsigned char x/u8 x/ in olpc_xo175_ec_resume() - Use GENMASK() instead of 0x for the event mask - Replace cmd tx/resp rx buffers with structures - Turned suspend hint arguments into a struct, and tidied up the comment Basically all of the above is based on the review by Andy Shevchenko. drivers/platform/olpc/Kconfig | 15 + drivers/platform/olpc/Makefile| 1 + drivers/platform/olpc/olpc-xo175-ec.c | 763 ++ 3 files changed, 779 insertions(+) create mode 100644 drivers/platform/olpc/olpc-xo175-ec.c diff --git a/drivers/platform/olpc/Kconfig b/drivers/platform/olpc/Kconfig index 7b736c9e67ac..7c643d24ad0f 100644 --- a/drivers/platform/olpc/Kconfig +++ b/drivers/platform/olpc/Kconfig @@ -9,3 +9,18 @@ config OLPC help Add support for detecting the unique features of the OLPC XO hardware. + +if OLPC + +config OLPC_XO175_EC + tristate "OLPC XO 1.75 Embedded Controller" + depends on ARCH_MMP || COMPILE_TEST + select SPI_SLAVE + help + Include support for the OLPC XO Embedded Controller (EC). The EC + provides various platform services, including support for the power, + button, restart, shutdown and battery charging status. + + Unless you have an OLPC XO laptop, you will want to say N. + +endif diff --git a/drivers/platform/olpc/Makefile b/drivers/platform/olpc/Makefile index dc8b26bc7209..5b43f383289e 100644 --- a/drivers/platform/olpc/Makefile +++ b/drivers/platform/olpc/Makefile @@ -2,3 +2,4 @@ # OLPC XO platform-specific drivers # obj-$(CONFIG_OLPC) += olpc-ec.o +obj-$(CONFIG_OLPC_XO175_EC)+= olpc-xo175-ec.o diff --git a/drivers/platform/olpc/olpc-xo175-ec.c b/drivers/platform/olpc/olpc-xo175-ec.c new file mode 100644 index ..74db06bacc44 --- /dev/null +++ b/drivers/platform/olpc/olpc-xo175-ec.c @@ -0,0 +1,763 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for the OLPC XO-1.75 Embedded Controller. + * + * The EC protocol is documented at: + * http://wiki.laptop.org/go/XO_1.75_HOST_to_EC_Protocol + * + * Copyright (C) 2010 One Laptop per Child Foundation. + * Copyright (C) 2018 Lubomir Rintel + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct ec_cmd_t { + u8 cmd; + u8 bytes_returned; +}; + +enum ec_chan_t { + CHAN_NONE = 0, + CHAN_SWITCH, + CHAN_CMD_RESP, + CHAN_KEYBOARD, + CHAN_TOUCHPAD, + CHAN_EVENT, + CHAN_DEBUG, + CHAN_CMD_ERROR, +}; + +/* + * EC events + */ +#define EVENT_AC_CHANGE1 /* AC plugged/unplugged */ +#define EVENT_BATTERY_STATUS 2 /* Battery low/full/error/gone */ +#define EVENT_BATTERY_CRITICAL 3 /* Battery critical voltage */ +#define EVENT_BATTERY_SOC_CHANGE 4 /* 1% SOC Change */ +#define EVENT_BATTERY_ERROR5 /* Abnormal error, query for cause */ +#define EVENT_POWER_PRESSED6 /* Power button was pressed */ +#define EVENT_POWER_PRESS_WAKE 7 /* Woken up with a power button */ +#define EVENT_TIMED_HOST_WAKE 8 /* Host wake timer */ +#define EVENT_OLS_HIGH_LIMIT 9 /* OLS crossed dark threshold */ +#define EVENT_OLS_LOW_LIMIT10 /* OLS crossed light threshold */ + +/* + * EC commands + * (from http://dev.laptop.org/git/users/rsmith/ec-1.75/tree/ec_cmd.h) + */ +#define CMD_GET_API_VERSION0x08 /* out: u8 */ +#define CMD_READ_VOLTAGE 0x10 /* out: u16, *9.76/32, mV */ +#define CMD_READ_CURRENT 0x11 /* out: s16, *15.625/120, mA */ +#define CMD_READ_ACR 0x12 /* out: s16, *6250/15, uAh */ +#define CMD_READ_BATT_TEMPERATURE 0x13 /* out: u16, *100/256, deg C */ +#define CMD_READ_AMBIENT_TEMPERATURE 0x14 /* unimplemented, no hardware */ +#define CMD_READ_BATTERY_STATUS0x15 /* out: u8, bitmask
[PATCH v2 17/17] power: supply: olpc_battery: Add OLPC XO 1.75 support
The battery and the protocol are essentially the same as OLPC XO 1.5, but the responses from the EC are LSB first. Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - s/s16 ecword_to_cpu/u16 ecword_to_cpu/ - s/u16 ec_byte/u16 ec_word/ drivers/power/supply/olpc_battery.c | 23 ++- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index ec5dfb8fcb8a..898e8a6128bb 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -56,6 +56,7 @@ struct olpc_battery_data { struct power_supply *olpc_bat; char bat_serial[17]; int new_proto; + int little_endian; }; /* @@ -321,6 +322,14 @@ static int olpc_bat_get_voltage_max_design(union power_supply_propval *val) return ret; } +static u16 ecword_to_cpu(struct olpc_battery_data *data, u16 ec_word) +{ + if (data->little_endian) + return le16_to_cpu(ec_word); + else + return be16_to_cpu(ec_word); +} + /* * Battery properties */ @@ -393,7 +402,7 @@ static int olpc_bat_get_property(struct power_supply *psy, if (ret) return ret; - val->intval = (s16)be16_to_cpu(ec_word) * 9760L / 32; + val->intval = ecword_to_cpu(data, ec_word) * 9760L / 32; break; case POWER_SUPPLY_PROP_CURRENT_AVG: case POWER_SUPPLY_PROP_CURRENT_NOW: @@ -401,7 +410,7 @@ static int olpc_bat_get_property(struct power_supply *psy, if (ret) return ret; - val->intval = (s16)be16_to_cpu(ec_word) * 15625L / 120; + val->intval = ecword_to_cpu(data, ec_word) * 15625L / 120; break; case POWER_SUPPLY_PROP_CAPACITY: ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1); @@ -432,21 +441,21 @@ static int olpc_bat_get_property(struct power_supply *psy, if (ret) return ret; - val->intval = (s16)be16_to_cpu(ec_word) * 10 / 256; + val->intval = ecword_to_cpu(data, ec_word) * 10 / 256; break; case POWER_SUPPLY_PROP_TEMP_AMBIENT: ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2); if (ret) return ret; - val->intval = (int)be16_to_cpu(ec_word) * 10 / 256; + val->intval = (int)ecword_to_cpu(data, ec_word) * 10 / 256; break; case POWER_SUPPLY_PROP_CHARGE_COUNTER: ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2); if (ret) return ret; - val->intval = (s16)be16_to_cpu(ec_word) * 6250 / 15; + val->intval = ecword_to_cpu(data, ec_word) * 6250 / 15; break; case POWER_SUPPLY_PROP_SERIAL_NUMBER: ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8); @@ -626,6 +635,10 @@ static int olpc_battery_probe(struct platform_device *pdev) if (ecver > 0x44) { /* XO 1 or 1.5 with a new EC firmware. */ data->new_proto = 1; + } else if (of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")) { + /* XO 1.75 */ + data->new_proto = 1; + data->little_endian = 1; } else if (ecver < 0x44) { /* * We've seen a number of EC protocol changes; this driver -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 08/17] Platform: OLPC: Move EC-specific functionality out from x86
Move the olpc-ec driver away from the X86 OLPC platform so that it could be used by the ARM based laptops too. Notably, the driver for the OLPC battery, which is also used on the ARM models, builds on this driver's interface. It is actually plaform independent: the OLPC EC commands with their argument and responses are mostly the same despite the delivery mechanism is different. Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - Cosmetic changes in line wrapping. - Remove an old extra copy of EC_SCI_* defines - Change version to u8 - Explain which parts are platform independent are in the commit message arch/x86/include/asm/olpc.h | 31 - arch/x86/platform/olpc/olpc.c | 119 +--- drivers/platform/olpc/olpc-ec.c | 99 +- include/linux/olpc-ec.h | 32 - 4 files changed, 145 insertions(+), 136 deletions(-) diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h index c2bf1de5d901..6fe76282aceb 100644 --- a/arch/x86/include/asm/olpc.h +++ b/arch/x86/include/asm/olpc.h @@ -9,12 +9,10 @@ struct olpc_platform_t { int flags; uint32_t boardrev; - int ecver; }; #define OLPC_F_PRESENT 0x01 #define OLPC_F_DCON0x02 -#define OLPC_F_EC_WIDE_SCI 0x04 #ifdef CONFIG_OLPC @@ -64,13 +62,6 @@ static inline int olpc_board_at_least(uint32_t rev) return olpc_platform_info.boardrev >= rev; } -extern void olpc_ec_wakeup_set(u16 value); -extern void olpc_ec_wakeup_clear(u16 value); -extern bool olpc_ec_wakeup_available(void); - -extern int olpc_ec_mask_write(u16 bits); -extern int olpc_ec_sci_query(u16 *sci_value); - #else static inline int machine_is_olpc(void) @@ -83,14 +74,6 @@ static inline int olpc_has_dcon(void) return 0; } -static inline void olpc_ec_wakeup_set(u16 value) { } -static inline void olpc_ec_wakeup_clear(u16 value) { } - -static inline bool olpc_ec_wakeup_available(void) -{ - return false; -} - #endif #ifdef CONFIG_OLPC_XO1_PM @@ -101,20 +84,6 @@ extern void olpc_xo1_pm_wakeup_clear(u16 value); extern int pci_olpc_init(void); -/* SCI source values */ - -#define EC_SCI_SRC_EMPTY 0x00 -#define EC_SCI_SRC_GAME0x01 -#define EC_SCI_SRC_BATTERY 0x02 -#define EC_SCI_SRC_BATSOC 0x04 -#define EC_SCI_SRC_BATERR 0x08 -#define EC_SCI_SRC_EBOOK 0x10/* XO-1 only */ -#define EC_SCI_SRC_WLAN0x20/* XO-1 only */ -#define EC_SCI_SRC_ACPWR 0x40 -#define EC_SCI_SRC_BATCRIT 0x80 -#define EC_SCI_SRC_GPWAKE 0x100 /* XO-1.5 only */ -#define EC_SCI_SRC_ALL 0x1FF - /* GPIO assignments */ #define OLPC_GPIO_MIC_AC 1 diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c index f0e920fb98ad..c6c62b4f251f 100644 --- a/arch/x86/platform/olpc/olpc.c +++ b/arch/x86/platform/olpc/olpc.c @@ -30,9 +30,6 @@ struct olpc_platform_t olpc_platform_info; EXPORT_SYMBOL_GPL(olpc_platform_info); -/* EC event mask to be applied during suspend (defining wakeup sources). */ -static u16 ec_wakeup_mask; - /* what the timeout *should* be (in ms) */ #define EC_BASE_TIMEOUT 20 @@ -186,83 +183,6 @@ static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, return ret; } -void olpc_ec_wakeup_set(u16 value) -{ - ec_wakeup_mask |= value; -} -EXPORT_SYMBOL_GPL(olpc_ec_wakeup_set); - -void olpc_ec_wakeup_clear(u16 value) -{ - ec_wakeup_mask &= ~value; -} -EXPORT_SYMBOL_GPL(olpc_ec_wakeup_clear); - -/* - * Returns true if the compile and runtime configurations allow for EC events - * to wake the system. - */ -bool olpc_ec_wakeup_available(void) -{ - if (!machine_is_olpc()) - return false; - - /* -* XO-1 EC wakeups are available when olpc-xo1-sci driver is -* compiled in -*/ -#ifdef CONFIG_OLPC_XO1_SCI - if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) /* XO-1 */ - return true; -#endif - - /* -* XO-1.5 EC wakeups are available when olpc-xo15-sci driver is -* compiled in -*/ -#ifdef CONFIG_OLPC_XO15_SCI - if (olpc_platform_info.boardrev >= olpc_board_pre(0xd0)) /* XO-1.5 */ - return true; -#endif - - return false; -} -EXPORT_SYMBOL_GPL(olpc_ec_wakeup_available); - -int olpc_ec_mask_write(u16 bits) -{ - if (olpc_platform_info.flags & OLPC_F_EC_WIDE_SCI) { - __be16 ec_word = cpu_to_be16(bits); - return olpc_ec_cmd(EC_WRITE_EXT_SCI_MASK, (void *) &ec_word, 2, - NULL, 0); - } else { - unsigned char ec_byte = bits & 0xff; - return olpc_ec_cmd(EC_WRITE_SCI_MASK, &ec_byte, 1, NULL, 0); - } -} -EXPORT_SYMBOL_GPL(olpc_ec_mask_write); - -int olpc_ec_sci_query(u16 *sci_value) -{ - int ret; - - if (olpc_platform_info.flags & OLPC_F_EC_WIDE_SCI) { -
[PATCH v2 14/17] power: supply: olpc_battery: Move priv data to a struct
The global variables for private data are not too nice. I'd like some more, and that would clutter the global name space even further. Signed-off-by: Lubomir Rintel Reviewed-by: Andy Shevchenko --- Changes since v1: - Split out the move to devm_* into a separate patch drivers/power/supply/olpc_battery.c | 68 + 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index 5323987d9284..b091f897c1d4 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -53,6 +53,12 @@ #define BAT_ADDR_MFR_TYPE 0x5F +struct olpc_battery_data { + struct power_supply *olpc_ac; + struct power_supply *olpc_bat; + char bat_serial[17]; +}; + /* * Power */ @@ -91,11 +97,8 @@ static const struct power_supply_desc olpc_ac_desc = { .get_property = olpc_ac_get_prop, }; -static struct power_supply *olpc_ac; - -static char bat_serial[17]; /* Ick */ - -static int olpc_bat_get_status(union power_supply_propval *val, uint8_t ec_byte) +static int olpc_bat_get_status(struct olpc_battery_data *data, + union power_supply_propval *val, uint8_t ec_byte) { if (olpc_platform_info.ecver > 0x44) { if (ec_byte & (BAT_STAT_CHARGING | BAT_STAT_TRICKLE)) @@ -326,6 +329,7 @@ static int olpc_bat_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { + struct olpc_battery_data *data = power_supply_get_drvdata(psy); int ret = 0; __be16 ec_word; uint8_t ec_byte; @@ -347,7 +351,7 @@ static int olpc_bat_get_property(struct power_supply *psy, switch (psp) { case POWER_SUPPLY_PROP_STATUS: - ret = olpc_bat_get_status(val, ec_byte); + ret = olpc_bat_get_status(data, val, ec_byte); if (ret) return ret; break; @@ -450,8 +454,8 @@ static int olpc_bat_get_property(struct power_supply *psy, if (ret) return ret; - sprintf(bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf)); - val->strval = bat_serial; + sprintf(data->bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf)); + val->strval = data->bat_serial; break; case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: ret = olpc_bat_get_voltage_max_design(val); @@ -579,17 +583,17 @@ static struct power_supply_desc olpc_bat_desc = { .use_for_apm = 1, }; -static struct power_supply *olpc_bat; - static int olpc_battery_suspend(struct platform_device *pdev, pm_message_t state) { - if (device_may_wakeup(&olpc_ac->dev)) + struct olpc_battery_data *data = platform_get_drvdata(pdev); + + if (device_may_wakeup(&data->olpc_ac->dev)) olpc_ec_wakeup_set(EC_SCI_SRC_ACPWR); else olpc_ec_wakeup_clear(EC_SCI_SRC_ACPWR); - if (device_may_wakeup(&olpc_bat->dev)) + if (device_may_wakeup(&data->olpc_bat->dev)) olpc_ec_wakeup_set(EC_SCI_SRC_BATTERY | EC_SCI_SRC_BATSOC | EC_SCI_SRC_BATERR); else @@ -601,7 +605,8 @@ static int olpc_battery_suspend(struct platform_device *pdev, static int olpc_battery_probe(struct platform_device *pdev) { - int ret; + struct power_supply_config psy_cfg = {}; + struct olpc_battery_data *data; uint8_t status; /* @@ -620,9 +625,13 @@ static int olpc_battery_probe(struct platform_device *pdev) /* Ignore the status. It doesn't actually matter */ - olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, NULL); - if (IS_ERR(olpc_ac)) - return PTR_ERR(olpc_ac); + psy_cfg.of_node = pdev->dev.of_node; + psy_cfg.drv_data = data; + + data->olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, &psy_cfg); + if (IS_ERR(data->olpc_ac)) + return PTR_ERR(data->olpc_ac); + if (of_property_match_string(pdev->dev.of_node, "compatible", "olpc,xo1.5-battery") >= 0) { /* XO-1.5 */ @@ -634,42 +643,45 @@ static int olpc_battery_probe(struct platform_device *pdev) olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props); } - olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, NULL); + data->olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, &psy_cfg); if (IS_ERR(olpc_bat)) { ret = PTR_ERR(olpc_bat); goto battery_failed;
[PATCH v2 11/17] dt-bindings: olpc_battery: Add XO-1.5 battery
The XO-1 and XO-1.5 batteries apparently differ in an ability to report ambient temperature. Signed-off-by: Lubomir Rintel Reviewed-by: Rob Herring Acked-by: Pavel Machek --- Changes since v1: - Collected Reviewed-by and Acked-by tags Documentation/devicetree/bindings/power/supply/olpc_battery.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/power/supply/olpc_battery.txt b/Documentation/devicetree/bindings/power/supply/olpc_battery.txt index c8901b3992d9..8d87d6b35a98 100644 --- a/Documentation/devicetree/bindings/power/supply/olpc_battery.txt +++ b/Documentation/devicetree/bindings/power/supply/olpc_battery.txt @@ -2,4 +2,4 @@ OLPC battery Required properties: - - compatible : "olpc,xo1-battery" + - compatible : "olpc,xo1-battery" or "olpc,xo1.5-battery" -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 16/17] power: supply: olpc_battery: Avoid using platform_info
This wouldn't work on the DT-based ARM platform. Let's read the EC version directly from the EC driver instead. This makes the driver no longer x86 specific. Signed-off-by: Lubomir Rintel Acked-by: Pavel Machek --- Changes since v1: - Use uint8_t instead of unsigned char [1] for ecver drivers/power/supply/Kconfig| 2 +- drivers/power/supply/olpc_battery.c | 35 + 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index f27cf0709500..dd7ae1431098 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -151,7 +151,7 @@ config BATTERY_PMU config BATTERY_OLPC tristate "One Laptop Per Child battery" - depends on X86_32 && OLPC + depends on OLPC help Say Y to enable support for the battery on the OLPC laptop. diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c index 4433eb10a23d..ec5dfb8fcb8a 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -20,8 +20,6 @@ #include #include #include -#include - #define EC_BAT_VOLTAGE 0x10/* uint16_t,*9.76/32,mV */ #define EC_BAT_CURRENT 0x11/* int16_t, *15.625/120, mA */ @@ -57,6 +55,7 @@ struct olpc_battery_data { struct power_supply *olpc_ac; struct power_supply *olpc_bat; char bat_serial[17]; + int new_proto; }; /* @@ -100,7 +99,7 @@ static const struct power_supply_desc olpc_ac_desc = { static int olpc_bat_get_status(struct olpc_battery_data *data, union power_supply_propval *val, uint8_t ec_byte) { - if (olpc_platform_info.ecver > 0x44) { + if (data->new_proto) { if (ec_byte & (BAT_STAT_CHARGING | BAT_STAT_TRICKLE)) val->intval = POWER_SUPPLY_STATUS_CHARGING; else if (ec_byte & BAT_STAT_DISCHARGING) @@ -608,14 +607,32 @@ static int olpc_battery_probe(struct platform_device *pdev) struct power_supply_config psy_cfg = {}; struct olpc_battery_data *data; uint8_t status; + uint8_t ecver; + int ret; + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + platform_set_drvdata(pdev, data); + + /* See if the EC is already there and get the EC revision */ + ret = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ecver, 1); + if (ret) { + if (ret == -ENODEV) + return -EPROBE_DEFER; + return ret; + } - /* -* We've seen a number of EC protocol changes; this driver requires -* the latest EC protocol, supported by 0x44 and above. -*/ - if (olpc_platform_info.ecver < 0x44) { + if (ecver > 0x44) { + /* XO 1 or 1.5 with a new EC firmware. */ + data->new_proto = 1; + } else if (ecver < 0x44) { + /* +* We've seen a number of EC protocol changes; this driver +* requires the latest EC protocol, supported by 0x44 and above. +*/ printk(KERN_NOTICE "OLPC EC version 0x%02x too old for " - "battery driver.\n", olpc_platform_info.ecver); + "battery driver.\n", ecver); return -ENXIO; } -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 08/15] ARM/arm64: sunxi: Move H3/H5 syscon label over to soc-specific nodes
Hi, On Fri, Nov 16, 2018 at 05:47:50PM +0800, Chen-Yu Tsai wrote: > On Fri, Nov 16, 2018 at 5:39 PM Maxime Ripard > wrote: > > > > On Thu, Nov 15, 2018 at 03:50:06PM +0100, Paul Kocialkowski wrote: > > > Now that we have specific nodes for the H3 and H5 system-controller > > > that allow proper access to the EMAC clock configuration register, > > > we no longer need a common dummy syscon node. > > > > > > Switch the syscon label over to each platform's dtsi file. > > > > > > Signed-off-by: Paul Kocialkowski > > > --- > > > arch/arm/boot/dts/sun8i-h3.dtsi | 2 +- > > > arch/arm/boot/dts/sunxi-h3-h5.dtsi | 6 -- > > > arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 2 +- > > > 3 files changed, 2 insertions(+), 8 deletions(-) > > > > > > diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi > > > b/arch/arm/boot/dts/sun8i-h3.dtsi > > > index 7157d954fb8c..b337a9282783 100644 > > > --- a/arch/arm/boot/dts/sun8i-h3.dtsi > > > +++ b/arch/arm/boot/dts/sun8i-h3.dtsi > > > @@ -134,7 +134,7 @@ > > > }; > > > > > > soc { > > > - system-control@1c0 { > > > + syscon: system-control@1c0 { > > > compatible = "allwinner,sun8i-h3-system-control"; > > > reg = <0x01c0 0x1000>; > > > #address-cells = <1>; > > > diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > > b/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > > index 4b1530ebe427..9175ff0fb59a 100644 > > > --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > > +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi > > > @@ -152,12 +152,6 @@ > > > }; > > > }; > > > > > > - syscon: syscon@1c0 { > > > - compatible = "allwinner,sun8i-h3-system-controller", > > > - "syscon"; > > > - reg = <0x01c0 0x1000>; > > > - }; > > > - > > > > You're also dropping the syscon compatible there. But I'm not sure how > > it could work with the H3 EMAC driver that would overwrite the > > compatible already. > > I assume you are referring to the previous patch? The node names are not > the same, hence the previous patch is adding another node for the system > controller, and this patch removes the old one with the "syscon" compatible. > > We already patched the EMAC driver to support the new SRAM controller based > regmap, so other than making people unhappy about having to update their > DT, I don't think there would be any problems. This also means H3 in -next > currently has _two_ syscon nodes. Ah, indeed, I missed that. Pointing that out in the commit log could be nice though. Thanks! Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v4 4/4] staging: iio: ad7816: Add device tree table.
On Thu, 15 Nov 2018 19:55:06 +0530 Nishad Kamdar wrote: > On Thu, Nov 15, 2018 at 08:16:03AM +, Ardelean, Alexandru wrote: > > On Wed, 2018-11-14 at 23:16 +0530, Nishad Kamdar wrote: > > > Add device tree table for matching vendor ID. > > > > > > > This could have been just one patch. > > Something like > >[PATCH v4] staging: iio: ad7816: Add device tree table. > > > > It's no longer a series, because the other patches were applied already. > > > > I don't think you need to re-spin this [it's up to Jonathan though]. > > > > It's just something to keep in mind for later when re-spinning patches or > > series of patches. > > > > Alex > > > > Ok. I'll keep that in mind. > > Thanks for the review. > > Regards, > Nishad > > > > Signed-off-by: Nishad Kamdar > > > --- > > > drivers/staging/iio/adc/ad7816.c | 9 + > > > 1 file changed, 9 insertions(+) > > > > > > diff --git a/drivers/staging/iio/adc/ad7816.c > > > b/drivers/staging/iio/adc/ad7816.c > > > index a2fead85cd46..925f7086bc07 100644 > > > --- a/drivers/staging/iio/adc/ad7816.c > > > +++ b/drivers/staging/iio/adc/ad7816.c > > > @@ -422,6 +422,14 @@ static int ad7816_probe(struct spi_device *spi_dev) > > > return 0; > > > } > > > > > > +static const struct of_device_id ad7816_of_match[] = { > > > + { .compatible = "adi,ad7816", }, > > > + { .compatible = "adi,ad7817", }, > > > + { .compatible = "adi,ad7818", }, > > > + { } > > > +}; > > > +MODULE_DEVICE_TABLE(of, ad7816_of_match); > > > + > > > static const struct spi_device_id ad7816_id[] = { > > > { "ad7816", ID_AD7816 }, > > > { "ad7817", ID_AD7817 }, > > > @@ -434,6 +442,7 @@ MODULE_DEVICE_TABLE(spi, ad7816_id); > > > static struct spi_driver ad7816_driver = { > > > .driver = { > > > .name = "ad7816", > > > + .of_match_table = of_match_ptr(ad7816_of_match), Also, don't use of_match_ptr, it defines the table to NULL if CONFIG_OF is not set, which breaks the ACPI based probing using the magic number to tell it to use the DT bindings (weird corner case). One of those really obscure corners cases (and one that hasn't existed for that long!) I'll fix up. Applied to to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > > > }, > > > .probe = ad7816_probe, > > > .id_table = ad7816_id, ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH RFC 0/6] mm/kdump: allow to exclude pages that are logically offline
On 14.11.18 22:16, David Hildenbrand wrote: > Right now, pages inflated as part of a balloon driver will be dumped > by dump tools like makedumpfile. While XEN is able to check in the > crash kernel whether a certain pfn is actuall backed by memory in the > hypervisor (see xen_oldmem_pfn_is_ram) and optimize this case, dumps of > virtio-balloon and hv-balloon inflated memory will essentially result in > zero pages getting allocated by the hypervisor and the dump getting > filled with this data. > > The allocation and reading of zero pages can directly be avoided if a > dumping tool could know which pages only contain stale information not to > be dumped. > > Also for XEN, calling into the kernel and asking the hypervisor if a > pfn is backed can be avoided if the duming tool would skip such pages > right from the beginning. > > Dumping tools have no idea whether a given page is part of a balloon driver > and shall not be dumped. Esp. PG_reserved cannot be used for that purpose > as all memory allocated during early boot is also PG_reserved, see > discussion at [1]. So some other way of indication is required and a new > page flag is frowned upon. > > We have PG_balloon (MAPCOUNT value), which is essentially unused now. I > suggest renaming it to something more generic (PG_offline) to mark pages as > logically offline. This flag can than e.g. also be used by virtio-mem in > the future to mark subsections as offline. Or by other code that wants to > put pages logically offline (e.g. later maybe poisoned pages that shall > no longer be used). > > This series converts PG_balloon to PG_offline, allows dumping tools to > query the value to detect such pages and marks pages in the hv-balloon > and XEN balloon properly as PG_offline. Note that virtio-balloon already > set pages to PG_balloon (and now PG_offline). > > Please note that this is also helpful for a problem we were seeing under > Hyper-V: Dumping logically offline memory (pages kept fake offline while > onlining a section via online_page_callback) would under some condicions > result in a kernel panic when dumping them. > > As I don't have access to neither XEN nor Hyper-V installation, this was > not tested yet (and a makedumpfile change will be required to skip > dumping these pages). > > [1] https://lkml.org/lkml/2018/7/20/566 > > David Hildenbrand (6): > mm: balloon: update comment about isolation/migration/compaction > mm: convert PG_balloon to PG_offline > kexec: export PG_offline to VMCOREINFO > xen/balloon: mark inflated pages PG_offline > hv_balloon: mark inflated pages PG_offline > PM / Hibernate: exclude all PageOffline() pages > > Documentation/admin-guide/mm/pagemap.rst | 6 + > drivers/hv/hv_balloon.c | 14 -- > drivers/xen/balloon.c| 3 +++ > fs/proc/page.c | 4 +-- > include/linux/balloon_compaction.h | 34 +--- > include/linux/page-flags.h | 11 +--- > include/uapi/linux/kernel-page-flags.h | 1 + > kernel/crash_core.c | 2 ++ > kernel/power/snapshot.c | 5 +++- > tools/vm/page-types.c| 1 + > 10 files changed, 51 insertions(+), 30 deletions(-) > I just did a test with virtio-balloon (and a very simple makedumpfile patch which I can supply on demand). 1. Guest with 8GB. Inflate balloon to 4GB via sudo virsh setmem f29 --size 4096M --live 2. Trigger a kernel panic in the guest echo 1 > /proc/sys/kernel/sysrq echo c > /proc/sysrq-trigger Original pages : 0x001e1da8 Excluded pages : 0x001c9221 Pages filled with zero : 0x50b0 Non-private cache pages : 0x00046547 Private cache pages : 0x2165 User process data pages : 0x48cf Free pages : 0x000771f6 Hwpoison pages : 0x Offline pages : 0x0010 Remaining pages : 0x00018b87 (The number of pages is reduced to 5%.) Memory Hole : 0x0009e258 -- Total pages : 0x0028 (Offline patches matches the 4GB) -- Thanks, David / dhildenb ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v4 1/2] staging: iio: ad7780: update voltage on read
On Mon, 12 Nov 2018 07:57:24 + "Ardelean, Alexandru" wrote: > On Sun, 2018-11-11 at 14:30 +, Jonathan Cameron wrote: > > On Tue, 6 Nov 2018 09:24:44 + > > "Ardelean, Alexandru" wrote: > > > > > On Mon, 2018-11-05 at 17:14 -0200, Renato Lui Geh wrote: > > > > The ad7780 driver previously did not read the correct device output, > > > > as > > > > it read an outdated value set at initialization. It now updates its > > > > voltage on read. > > > > > > > > Applied to the togreg branch of iio.git and pushed out as testing for > > the autobuilders to check it. I'm not that fussed about pushing this > > one as a fix, as most of the time these things are on fixed regulators > > anyway, but it is nice to do it right. > > > > > Looks good from my side. > > > > Ack? > > Acked-by: Alexandru Ardelean Added to both in this series. Thanks, Jonathan > > > > > Much preferred if you are willing to give a formal acknowledgement. > > > > Thanks, > > > > Jonathan > > > > > > > > > > Alex > > > > > > > Signed-off-by: Renato Lui Geh > > > > --- > > > > Changes in v3: > > > > - removed initialization (int voltage_uv = 0) > > > > - returns error when voltage_uv is null > > > > Changes in v4: > > > > - returns error when voltage_uv is negative > > > > > > > > drivers/staging/iio/adc/ad7780.c | 6 +- > > > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/staging/iio/adc/ad7780.c > > > > b/drivers/staging/iio/adc/ad7780.c > > > > index b67412db0318..c7cb05cedbbc 100644 > > > > --- a/drivers/staging/iio/adc/ad7780.c > > > > +++ b/drivers/staging/iio/adc/ad7780.c > > > > @@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev > > > > *indio_dev, > > > >long m) > > > > { > > > > struct ad7780_state *st = iio_priv(indio_dev); > > > > + int voltage_uv; > > > > > > > > switch (m) { > > > > case IIO_CHAN_INFO_RAW: > > > > return ad_sigma_delta_single_conversion(indio_dev, chan, > > > > val); > > > > case IIO_CHAN_INFO_SCALE: > > > > - *val = st->int_vref_mv * st->gain; > > > > + voltage_uv = regulator_get_voltage(st->reg); > > > > + if (voltage_uv < 0) > > > > + return voltage_uv; > > > > + *val = (voltage_uv / 1000) * st->gain; > > > > *val2 = chan->scan_type.realbits - 1; > > > > return IIO_VAL_FRACTIONAL_LOG2; > > > > case IIO_CHAN_INFO_OFFSET: > > > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 1/2] staging: iio: ad7780: check if ad778x before gain update
On Mon, 12 Nov 2018 07:57:58 + "Ardelean, Alexandru" wrote: > On Sun, 2018-11-11 at 12:58 +, Jonathan Cameron wrote: > > On Thu, 8 Nov 2018 13:44:17 + > > "Ardelean, Alexandru" wrote: > > > > > On Thu, 2018-11-08 at 11:03 -0200, Giuliano Belinassi wrote: > > > > Only the ad778x have the 'gain' status bit. Check it before updating > > > > through a new variable is_ad778x in chip_info. > > > > > > > > > > Looks good. > > > > Alex, formal tags definitely preferred! It's not as though a > > looks good is any less of a review than an Ack, it's just better > > hidden as people need to look at mailing list archives... > > > > Jonathan > > > > Acked-by: Alexandru Ardelean I haven't pushed out togreg yet so can still rebase. Added. Thanks, Jonathan > > // Will remember that next time :) > > Thanks > Alex > > > > > > > Alex > > > > > > > Signed-off-by: Giuliano Belinassi > > > > --- > > > > Changes in v2: > > > > - Squashed is_ad778x declaration commit with the ad778x checkage > > > > - Changed is_ad778x type to bool > > > > > > > > drivers/staging/iio/adc/ad7780.c | 15 +++ > > > > 1 file changed, 11 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/drivers/staging/iio/adc/ad7780.c > > > > b/drivers/staging/iio/adc/ad7780.c > > > > index 91e016d534ed..9ec2b002539e 100644 > > > > --- a/drivers/staging/iio/adc/ad7780.c > > > > +++ b/drivers/staging/iio/adc/ad7780.c > > > > @@ -35,6 +35,7 @@ struct ad7780_chip_info { > > > > struct iio_chan_specchannel; > > > > unsigned intpattern_mask; > > > > unsigned intpattern; > > > > + boolis_ad778x; > > > > }; > > > > > > > > struct ad7780_state { > > > > @@ -113,10 +114,12 @@ static int ad7780_postprocess_sample(struct > > > > ad_sigma_delta *sigma_delta, > > > > ((raw_sample & chip_info->pattern_mask) != > > > > chip_info->pattern)) > > > > return -EIO; > > > > > > > > - if (raw_sample & AD7780_GAIN) > > > > - st->gain = 1; > > > > - else > > > > - st->gain = 128; > > > > + if (chip_info->is_ad778x) { > > > > + if (raw_sample & AD7780_GAIN) > > > > + st->gain = 1; > > > > + else > > > > + st->gain = 128; > > > > + } > > > > > > > > return 0; > > > > } > > > > @@ -135,21 +138,25 @@ static const struct ad7780_chip_info > > > > ad7780_chip_info_tbl[] = { > > > > .channel = AD7780_CHANNEL(12, 24), > > > > .pattern = 0x5, > > > > .pattern_mask = 0x7, > > > > + .is_ad778x = false, > > > > }, > > > > [ID_AD7171] = { > > > > .channel = AD7780_CHANNEL(16, 24), > > > > .pattern = 0x5, > > > > .pattern_mask = 0x7, > > > > + .is_ad778x = false, > > > > }, > > > > [ID_AD7780] = { > > > > .channel = AD7780_CHANNEL(24, 32), > > > > .pattern = 0x1, > > > > .pattern_mask = 0x3, > > > > + .is_ad778x = true, > > > > }, > > > > [ID_AD7781] = { > > > > .channel = AD7780_CHANNEL(20, 32), > > > > .pattern = 0x1, > > > > .pattern_mask = 0x3, > > > > + .is_ad778x = true, > > > > }, > > > > }; > > > > > > > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/6] staging:iio:ad2s90: Remove spi setup that should be done via dt
On Thu, 15 Nov 2018 12:44:39 -0200 Matheus Tavares Bernardino wrote: > On Sun, Nov 11, 2018 at 9:42 AM Jonathan Cameron wrote: > > > > On Fri, 9 Nov 2018 20:00:40 -0200 > > Matheus Tavares wrote: > > > > > The ad2s90 driver currently sets some spi settings (max_speed_hz and > > > mode) at ad2s90_probe. This should, instead, be handled via device tree. > > > This patch removes these configurations from the probe function. > > > > > > Note: The way in which the mentioned spi settings need to be specified > > > on the ad2s90's node of a device tree will be documented in the future > > > patch "dt-bindings:iio:resolver: Add docs for ad2s90". > > > > > > Signed-off-by: Matheus Tavares > > I'd actually like to get Rob and Mark's views on this one. Previously > > I would just have applied it without thinking on the basis these can > > be easily specified from devicetree. > > > > Recent discussions with Rob have suggested that the settings in devicetree > > should perhaps be concerned with specifying constraints about the device > > that are not visible to the driver. The driver itself should apply > > the device constraints, but there are others such as wiring that > > might reduce the maximum frequency for example... > > > > So should a driver be clamping an over specified value from DT for > > example? Or given that is optional in DT, should it be making sure > > that a controller max frequency isn't too high for the sensor? > > > > First of all, thanks for the review and comments. > > By what you've said here and in the reviews for patches 3 and 4 of > this patch-set, it seems to me that the most reasonable thing would be > to keep the SPI mode 3 settings at the driver but the max frequency > setting at DT and check if it exceeds the maximum at the driver (as > patch 3 does). This makes sense to me, based on what you've said, > because mode 3 is a device constraint visible to the driver (as it > won't change) but max frequency is not (because of things such as > wiring, as you said). > > What do you think, Jonathan, Rob, and Mark? Sounds good to me. I just checked the DT bindings for spi-bus and max-frequency is indeed a required binding element for slave devices, hence has to be there. Best to confirm it is sane in the driver however as you suggest. I think we'll standardise on that bit of paranoia in IIO unless Rob or Mark shouts otherwise. Jonathan > > Matheus > > > It seems to be unusual to do this, but to my mind it would make > > sense and might be worth pushing out into more drivers. > > > > Jonathan > > > --- > > > drivers/staging/iio/resolver/ad2s90.c | 11 --- > > > 1 file changed, 11 deletions(-) > > > > > > diff --git a/drivers/staging/iio/resolver/ad2s90.c > > > b/drivers/staging/iio/resolver/ad2s90.c > > > index ff32ca76ca00..95c118c48400 100644 > > > --- a/drivers/staging/iio/resolver/ad2s90.c > > > +++ b/drivers/staging/iio/resolver/ad2s90.c > > > @@ -77,7 +77,6 @@ static int ad2s90_probe(struct spi_device *spi) > > > { > > > struct iio_dev *indio_dev; > > > struct ad2s90_state *st; > > > - int ret; > > > > > > indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); > > > if (!indio_dev) > > > @@ -94,16 +93,6 @@ static int ad2s90_probe(struct spi_device *spi) > > > indio_dev->num_channels = 1; > > > indio_dev->name = spi_get_device_id(spi)->name; > > > > > > - /* need 600ns between CS and the first falling edge of SCLK */ > > > - spi->max_speed_hz = 83; > > > - spi->mode = SPI_MODE_3; > > > - ret = spi_setup(spi); > > > - > > > - if (ret < 0) { > > > - dev_err(&spi->dev, "spi_setup failed!\n"); > > > - return ret; > > > - } > > > - > > > return devm_iio_device_register(indio_dev->dev.parent, indio_dev); > > > } > > > > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V4] binder: ipc namespace support for android binder
On Thu, Nov 15, 2018 at 2:54 PM gre...@linuxfoundation.org wrote: ... > > A number of us have talked about this in the plumbers Android track, and > a different proposal for how to solve this has been made that should be > much more resiliant. So I will drop this patch from my queue and wait > for the patches based on the discussions we had there. > > I think there's some notes/slides on the discussion online somewhere, > but it hasn't been published as the conference is still happening, > otherwise I would link to it here... Here is a link to the session where you can look at the slides [1]. There was consensus that "binderfs" (slide 5) was the most promising -- but would be behind a config option to provide backwards compatibility for non-container use-cases. The etherpad notes are at [2] (look at "Dynamically Allocated Binder Devices" section) Christian Brauner will be sending out more details. -Todd [1] https://linuxplumbersconf.org/event/2/contributions/222/ [2] https://etherpad.openstack.org/p/Android > > thanks, > > greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/7] Remove platform data and introduce DT bindings
This patchset introduces device tree bindings for adt7316 driver and removes the usage of platform data from it. Also, it sets the data field to it's appropriate value in the i2c read function which was nowhere being set before. Shreeya Patel (7): Staging: iio: adt7316: Set the data field Staging: iio: adt7316: Add an extra check for 'ret' equals to 0 Staging: iio: adt7316: Add of_device_id table Staging: iio: adt7316: Use device tree data to set ldac_pin Staging: iio: adt7316: Switch irq_flags to a local variable Staging: iio: adt7316: Change the name from irq_flags to irq_type Staging: iio: adt7316: Use device tree data to assign irq_type drivers/staging/iio/addac/adt7316-i2c.c | 19 +++- drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 39 ++--- drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 47 insertions(+), 13 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/7] Staging: iio: adt7316: Set the data field
adt7316_i2c_read function nowhere sets the data field. It is necessary to have an appropriate value for it. Hence, assign the value stored in 'ret' variable to data field. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index f66dd3ebbab1..856bcfa60c6c 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -35,6 +35,8 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) return ret; } + *data = ret; + return 0; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/7] Staging: iio: adt7316: Add an extra check for 'ret' equals to 0
ret = 0 indicates a case of no error but no data read from the bus which is an invalid case. This case doesn't ever happen in reality. It should perhaps be handled for correctness though. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 856bcfa60c6c..473e5e34ec00 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -30,6 +30,10 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) } ret = i2c_smbus_read_byte(client); + + if (!ret) + return -EIO; + if (ret < 0) { dev_err(&cl->dev, "I2C read error\n"); return ret; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/7] Staging: iio: adt7316: Add of_device_id table
When the kernel starts up, it kicks off compiled-in drivers that match “compatible” entries it finds in the device tree. At a later stage (when /lib/modules is available), all kernel modules that match “compatible” entries in the device tree are loaded. Hence to be able to use device tree for ADT7316, add of_device_id table which specifies the supported devices through compatible property. Note that there is a fall back path in i2c that will result in i2c_device_id table being used if there is no of_devcie_id table. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 473e5e34ec00..d4b5060c18ee 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -126,6 +126,18 @@ static const struct i2c_device_id adt7316_i2c_id[] = { MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id); +static const struct of_device_id adt7316_of_match[] = { + { .compatible = "adi,adt7316" }, + { .compatible = "adi,adt7317" }, + { .compatible = "adi,adt7318" }, + { .compatible = "adi,adt7516" }, + { .compatible = "adi,adt7517" }, + { .compatible = "adi,adt7519" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, adt7316_of_match); + static struct i2c_driver adt7316_driver = { .driver = { .name = "adt7316", -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/7] Staging: iio: adt7316: Use device tree data to set ldac_pin
Make the driver use device tree instead of the platform data. Hence, use devm_gpiod_get_optional function to get the data from device tree for ldac-pin and accordingly make the needed changes in the driver. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 3f22d1088713..deb2f7b40f60 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -177,7 +177,7 @@ struct adt7316_chip_info { struct adt7316_bus bus; - u16 ldac_pin; + struct gpio_desc*ldac_pin; u16 int_mask; /* 0x2f */ u8 config1; u8 config2; @@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, if (ret) return -EIO; } else { - gpio_set_value(chip->ldac_pin, 0); - gpio_set_value(chip->ldac_pin, 1); + gpiod_set_value(chip->ldac_pin, 0); + gpiod_set_value(chip->ldac_pin, 1); } return len; @@ -2120,7 +2120,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, else return -ENODEV; - chip->ldac_pin = adt7316_platform_data[1]; + chip->ldac_pin = devm_gpiod_get_optional(dev, "ldac", GPIOD_OUT_LOW); + if (IS_ERR(chip->ldac_pin)) { + ret = PTR_ERR(chip->ldac_pin); + dev_err(dev, "Failed to request ldac GPIO: %d\n", ret); + return ret; + } + if (chip->ldac_pin) { chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/7] Staging: iio: adt7316: Switch irq_flags to a local variable
There is no need to store irq_flags into the structure as it is always set to the same thing. Hence switch irq_flags to a local variable. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 1 - drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 8 drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index d4b5060c18ee..91d6cdcb747e 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -104,7 +104,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, struct adt7316_bus bus = { .client = client, .irq = client->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 5cd22743e140..e75827e326a6 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -94,7 +94,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) struct adt7316_bus bus = { .client = spi_dev, .irq = spi_dev->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index deb2f7b40f60..dfae22619287 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,6 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; + int irq_flags = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,19 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - chip->bus.irq_flags = adt7316_platform_data[0]; + irq_flags = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - chip->bus.irq_flags | - IRQF_ONESHOT, + irq_flags | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH) + if (irq_flags & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index ec40fbb698a6..fd7c5c92b599 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -17,7 +17,6 @@ struct adt7316_bus { void *client; int irq; - int irq_flags; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/7] Staging: iio: adt7316: Change the name from irq_flags to irq_type
Most of the drivers in IIO uses irq_type as the name for storing the interrupt type and hence change the name from irq_flags to irq_type for maintaining the consistency. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index dfae22619287..9c72538baf9e 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,7 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; - int irq_flags = IRQF_TRIGGER_LOW; + int irq_type = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2147,18 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - irq_flags = adt7316_platform_data[0]; + irq_type = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - irq_flags | IRQF_ONESHOT, + irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (irq_flags & IRQF_TRIGGER_HIGH) + if (irq_type & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/7] Staging: iio: adt7316: Use device tree data to assign irq_type
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 21 + 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..c647875a64f5 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2101,8 +2101,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; + int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,8 +2145,22 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; + irq_type = + irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: axis-fifo: Split line to stay in 80 characters.
The line is split up to stay in 80 characters- Signed-off-by: Cristian Sicilia --- drivers/staging/axis-fifo/axis-fifo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index c18bf31..805437f 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -485,7 +485,8 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf, ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) >= words_to_write, fifo->write_queue_lock, -(write_timeout >= 0) ? msecs_to_jiffies(write_timeout) : +(write_timeout >= 0) ? + msecs_to_jiffies(write_timeout) : MAX_SCHEDULE_TIMEOUT); spin_unlock_irq(&fifo->write_queue_lock); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/2] staging: emxx_udc: Fixing function naming
Fix function naming and parenthesis. Signed-off-by: Cristian Sicilia --- drivers/staging/emxx_udc/emxx_udc.c | 212 1 file changed, 70 insertions(+), 142 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 26bd77c..f391abe 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -163,11 +163,8 @@ static void _nbu2ss_ep0_complete(struct usb_ep *_ep, struct usb_request *_req) /*-*/ /* Initialization usb_request */ -static void _nbu2ss_create_ep0_packet( - struct nbu2ss_udc *udc, - void *p_buf, - unsigned length -) +static void _nbu2ss_create_ep0_packet(struct nbu2ss_udc *udc, + void *p_buf, unsigned int length) { udc->ep0_req.req.buf= p_buf; udc->ep0_req.req.length = length; @@ -419,12 +416,8 @@ static void _nbu2ss_ep_dma_abort(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) /*-*/ /* Start IN Transfer */ -static void _nbu2ss_ep_in_end( - struct nbu2ss_udc *udc, - u32 epnum, - u32 data32, - u32 length -) +static void _nbu2ss_ep_in_end(struct nbu2ss_udc *udc, + u32 epnum, u32 data32, u32 length) { u32 data; u32 num; @@ -462,12 +455,9 @@ static void _nbu2ss_ep_in_end( #ifdef USE_DMA /*-*/ -static void _nbu2ss_dma_map_single( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u8 direct -) +static void _nbu2ss_dma_map_single(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u8 direct) { if (req->req.dma == DMA_ADDR_INVALID) { if (req->unaligned) { @@ -496,12 +486,9 @@ static void _nbu2ss_dma_map_single( } /*-*/ -static void _nbu2ss_dma_unmap_single( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u8 direct -) +static void _nbu2ss_dma_unmap_single(struct nbu2ss_udc *udc, +struct nbu2ss_ep *ep, +struct nbu2ss_req *req, u8 direct) { u8 data[4]; u8 *p; @@ -672,10 +659,8 @@ static int EP0_receive_NULL(struct nbu2ss_udc *udc, bool pid_flag) } /*-*/ -static int _nbu2ss_ep0_in_transfer( - struct nbu2ss_udc *udc, - struct nbu2ss_req *req -) +static int _nbu2ss_ep0_in_transfer(struct nbu2ss_udc *udc, + struct nbu2ss_req *req) { u8 *p_buffer; /* IN Data Buffer */ u32 data; @@ -729,10 +714,8 @@ static int _nbu2ss_ep0_in_transfer( } /*-*/ -static int _nbu2ss_ep0_out_transfer( - struct nbu2ss_udc *udc, - struct nbu2ss_req *req -) +static int _nbu2ss_ep0_out_transfer(struct nbu2ss_udc *udc, + struct nbu2ss_req *req) { u8 *p_buffer; u32 i_remain_size; @@ -806,12 +789,8 @@ static int _nbu2ss_ep0_out_transfer( } /*-*/ -static int _nbu2ss_out_dma( - struct nbu2ss_udc *udc, - struct nbu2ss_req *req, - u32 num, - u32 length -) +static int _nbu2ss_out_dma(struct nbu2ss_udc *udc, struct nbu2ss_req *req, + u32 num, u32 length) { dma_addr_t p_buffer; u32 mpkt; @@ -869,12 +848,8 @@ static int _nbu2ss_out_dma( } /*-*/ -static int _nbu2ss_epn_out_pio( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u32 length -) +static int _nbu2ss_epn_out_pio(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u32 length) { u8 *p_buffer; u32 i; @@ -928,12 +903,8 @@ static int _nbu2ss_epn_out_pio( } /*-*/ -static int _nbu2ss_epn_out_data( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u32 data_size -) +static int _nbu2ss_epn_out_data(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, +
[PATCH 1/2] staging: emxx_udc: Split line and fix eol parenthesis
Fix some parenthesis opened at end of line. Signed-off-by: Cristian Sicilia --- drivers/staging/emxx_udc/emxx_udc.c | 73 ++--- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index bf7c5da..26bd77c 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -108,20 +108,20 @@ static void _nbu2ss_dump_register(struct nbu2ss_udc *udc) dev_dbg(&udc->dev, "\n-USB REG-\n"); for (i = 0x0 ; i < USB_BASE_SIZE ; i += 16) { - reg_data = _nbu2ss_readl( - (u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i)); + reg_data = _nbu2ss_readl((u32 *)IO_ADDRESS(USB_BASE_ADDRESS + + i)); dev_dbg(&udc->dev, "USB%04x =%08x", i, (int)reg_data); - reg_data = _nbu2ss_readl( - (u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i + 4)); + reg_data = _nbu2ss_readl((u32 *)IO_ADDRESS(USB_BASE_ADDRESS + + i + 4)); dev_dbg(&udc->dev, " %08x", (int)reg_data); - reg_data = _nbu2ss_readl( - (u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i + 8)); + reg_data = _nbu2ss_readl((u32 *)IO_ADDRESS(USB_BASE_ADDRESS + + i + 8)); dev_dbg(&udc->dev, " %08x", (int)reg_data); - reg_data = _nbu2ss_readl( - (u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i + 12)); + reg_data = _nbu2ss_readl((u32 *)IO_ADDRESS(USB_BASE_ADDRESS + + i + 12)); dev_dbg(&udc->dev, " %08x\n", (int)reg_data); } @@ -473,22 +473,23 @@ static void _nbu2ss_dma_map_single( if (req->unaligned) { req->req.dma = ep->phys_buf; } else { - req->req.dma = dma_map_single( - udc->gadget.dev.parent, - req->req.buf, - req->req.length, - (direct == USB_DIR_IN) - ? DMA_TO_DEVICE : DMA_FROM_DEVICE); + req->req.dma = + dma_map_single(udc->gadget.dev.parent, + req->req.buf, + req->req.length, + (direct == USB_DIR_IN) ? + DMA_TO_DEVICE : + DMA_FROM_DEVICE); } req->mapped = 1; } else { if (!req->unaligned) - dma_sync_single_for_device( - udc->gadget.dev.parent, - req->req.dma, - req->req.length, - (direct == USB_DIR_IN) - ? DMA_TO_DEVICE : DMA_FROM_DEVICE); + dma_sync_single_for_device(udc->gadget.dev.parent, + req->req.dma, + req->req.length, + (direct == USB_DIR_IN) + ? DMA_TO_DEVICE : + DMA_FROM_DEVICE); req->mapped = 0; } @@ -975,8 +976,8 @@ static int _nbu2ss_epn_out_transfer( /*-*/ /* Receive Length */ - i_recv_length - = _nbu2ss_readl(&preg->EP_REGS[num].EP_LEN_DCNT) & EPN_LDATA; + i_recv_length = + _nbu2ss_readl(&preg->EP_REGS[num].EP_LEN_DCNT) & EPN_LDATA; if (i_recv_length != 0) { result = _nbu2ss_epn_out_data(udc, ep, req, i_recv_length); @@ -1115,10 +1116,9 @@ static int _nbu2ss_epn_in_pio( i_word_length = length / sizeof(u32); if (i_word_length > 0) { for (i = 0; i < i_word_length; i++) { - _nbu2ss_writel( - &preg->EP_REGS[ep->epnum - 1].EP_WRITE - , p_buf_32->dw - ); + _nbu2ss_writel(&preg->EP_REGS[ep->epnum - + 1].EP_WRITE, + p_buf_32->dw); p_buf_32++; } @@ -1472,13 +1472,11 @@ static inline int _nbu2ss_req_feature(struct nbu2ss_udc *udc, bool bset) if (0x == (wIndex & 0xFF70)) {
[PATCH 0/2] Split line, fix eol parenthesis and fix functions
Patch 1: therea are some trying to split the line, but not shure about the result, like 1) reg_data = _nbu2ss_readl((u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i)); 2) regdata = _nbu2ss_readl(&preg->EP_REGS[ep->epnum - 1].EP_STATUS); The second patch try to fix the function, removing the parenthesis at end of line, and add new line only if needed (over 80 chars) Cristian Sicilia (2): staging: emxx_udc: Split line and fix eol parenthesis staging: emxx_udc: Fixing function naming drivers/staging/emxx_udc/emxx_udc.c | 285 ++-- 1 file changed, 106 insertions(+), 179 deletions(-) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 4/6] dt-bindings:iio:resolver: Add docs for ad2s90
On Sun, Nov 11, 2018 at 9:48 AM Jonathan Cameron wrote: > > On Fri, 9 Nov 2018 20:00:42 -0200 > Matheus Tavares wrote: > > > This patch adds the device tree binding documentation for the ad2s90 > > resolver-to-digital converter. > > > > Signed-off-by: Matheus Tavares > > --- > > .../bindings/iio/resolver/ad2s90.txt | 26 +++ > > 1 file changed, 26 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/iio/resolver/ad2s90.txt > > > > diff --git a/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt > > b/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt > > new file mode 100644 > > index ..b42cc7752ffd > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt > > @@ -0,0 +1,26 @@ > > +Analog Devices AD2S90 Resolver-to-Digital Converter > > + > > +https://www.analog.com/en/products/ad2s90.html > > + > > +Required properties: > > + - compatible : should be "adi,ad2s90" > > + - reg : SPI chip select number for the device > > + - spi-max-frequency : set maximum clock frequency, must be 83 > > + - spi-cpol and spi-cpha : must be defined to enable SPI mode 3 > > As the part only works in mode 3, my gut feeling is that this belongs > in the driver, not here. Rob, what do you think? > For this patch, I assumed the part only worked in mode 3 based on the driver's code that set this at probe. But today I carefully looked for it at the datasheet and now I'm unsure. It is never said, explicitly, which SPI mode ad2s90 works with. But looking at the diagram that shows the expected pins signals at each communication moment, it seems to me that this chip can either work in mode 0 (CPOL=0, CPHA=0) or mode 3 (CPOL=1, CPHA=1). Could someone help me to confirm this? And if that is the case, them the SPI mode setting should be left in DT, as adc/mcp320x and dac/ti-dac082s085 do, right? Also, when I thought that ad2s90 only worked in mode 3, I wrote this patch based on the dt-binding docs for the adxl345 accelerometer, which only works in mode 3 but lets this setting to DT not in the driver. Do you think, perhaps, it is wrong in adxl345, them? Thanks, Matheus. > > + > > +Note about max frequency: > > +Chip's max frequency, as specified in its datasheet, is 2Mhz. But a > > 600ns > > +delay is expected between the application of a logic LO to CS and the > > +application of SCLK, as also specified. And since the delay is not > > +implemented in the spi code, to satisfy it, SCLK's period should be at > > most > > +2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which gives > > +roughly 83Hz. > > + > > +Example: > > +resolver@0 { > > + compatible = "adi,ad2s90"; > > + reg = <0>; > > + spi-max-frequency = <83>; > > + spi-cpol; > > + spi-cpha; > > +}; > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: greybus: arche-platform: Switch to the gpio descriptor interface
On Fri, Nov 16, 2018 at 05:06:22PM +0100, Johan Hovold wrote: > On Fri, Nov 16, 2018 at 08:47:44PM +0530, Nishad Kamdar wrote: > > Use the gpiod interface instead of the deprecated > > old non-descriptor interface. > > > > Signed-off-by: Nishad Kamdar > > --- > > Always include a change log here after the cut-off line so we know what > changed since previous versions. > > Also include the patch revision in the Subject (e.g. "[PATCH v3] > staging: greybus: ..."). > Ok, but this is the first patch version that I submitted for greybus: arche-platform. > > drivers/staging/greybus/arche-platform.c | 120 --- > > 1 file changed, 42 insertions(+), 78 deletions(-) > > > > diff --git a/drivers/staging/greybus/arche-platform.c > > b/drivers/staging/greybus/arche-platform.c > > index 4c36e88766e7..a826a1835628 100644 > > --- a/drivers/staging/greybus/arche-platform.c > > +++ b/drivers/staging/greybus/arche-platform.c > > @@ -8,10 +8,9 @@ > > > > #include > > #include > > -#include > > +#include > > #include > > #include > > -#include > > #include > > #include > > #include > > @@ -45,14 +44,15 @@ enum svc_wakedetect_state { > > > > struct arche_platform_drvdata { > > /* Control GPIO signals to and from AP <=> SVC */ > > - int svc_reset_gpio; > > + struct gpio_desc *svc_reset; > > + struct gpio_desc *svc_sysboot; > > bool is_reset_act_hi; > > - int svc_sysboot_gpio; > > - int wake_detect_gpio; /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */ > > + struct gpio_desc *wake_detect; > > + /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */ > > I'm not commenting on the rest, but comments never go underneath what > they apply to. > > Just keep the current comment here, even if it's placement is a bit odd > and makes the line be longer than 80 cols. > > Johan Ok, I'll keep that in mind. Thanks for the review. thanks and regards, Nishad ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: greybus: arche-platform: Switch to the gpio descriptor interface
Use the gpiod interface instead of the deprecated old non-descriptor interface. Signed-off-by: Nishad Kamdar --- Changes in v2: - Move comment to the same line as to what it applies to. --- drivers/staging/greybus/arche-platform.c | 119 --- 1 file changed, 41 insertions(+), 78 deletions(-) diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c index 4c36e88766e7..a5cea79d8e32 100644 --- a/drivers/staging/greybus/arche-platform.c +++ b/drivers/staging/greybus/arche-platform.c @@ -8,10 +8,9 @@ #include #include -#include +#include #include #include -#include #include #include #include @@ -45,14 +44,14 @@ enum svc_wakedetect_state { struct arche_platform_drvdata { /* Control GPIO signals to and from AP <=> SVC */ - int svc_reset_gpio; + struct gpio_desc *svc_reset; + struct gpio_desc *svc_sysboot; bool is_reset_act_hi; - int svc_sysboot_gpio; - int wake_detect_gpio; /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */ + struct gpio_desc *wake_detect; /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */ enum arche_platform_state state; - int svc_refclk_req; + struct gpio_desc *svc_refclk_req; struct clk *svc_ref_clk; struct pinctrl *pinctrl; @@ -85,9 +84,9 @@ static void arche_platform_set_wake_detect_state( arche_pdata->wake_detect_state = state; } -static inline void svc_reset_onoff(unsigned int gpio, bool onoff) +static inline void svc_reset_onoff(struct gpio_desc *gpio, bool onoff) { - gpio_set_value(gpio, onoff); + gpiod_set_value(gpio, onoff); } static int apb_cold_boot(struct device *dev, void *data) @@ -116,7 +115,6 @@ static int apb_poweroff(struct device *dev, void *data) static void arche_platform_wd_irq_en(struct arche_platform_drvdata *arche_pdata) { /* Enable interrupt here, to read event back from SVC */ - gpio_direction_input(arche_pdata->wake_detect_gpio); enable_irq(arche_pdata->wake_detect_irq); } @@ -160,7 +158,7 @@ static irqreturn_t arche_platform_wd_irq(int irq, void *devid) spin_lock_irqsave(&arche_pdata->wake_lock, flags); - if (gpio_get_value(arche_pdata->wake_detect_gpio)) { + if (gpiod_get_value(arche_pdata->wake_detect)) { /* wake/detect rising */ /* @@ -224,10 +222,10 @@ arche_platform_coldboot_seq(struct arche_platform_drvdata *arche_pdata) dev_info(arche_pdata->dev, "Booting from cold boot state\n"); - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, arche_pdata->is_reset_act_hi); - gpio_set_value(arche_pdata->svc_sysboot_gpio, 0); + gpiod_set_value(arche_pdata->svc_sysboot, 0); usleep_range(100, 200); ret = clk_prepare_enable(arche_pdata->svc_ref_clk); @@ -238,7 +236,7 @@ arche_platform_coldboot_seq(struct arche_platform_drvdata *arche_pdata) } /* bring SVC out of reset */ - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, !arche_pdata->is_reset_act_hi); arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_ACTIVE); @@ -259,10 +257,10 @@ arche_platform_fw_flashing_seq(struct arche_platform_drvdata *arche_pdata) dev_info(arche_pdata->dev, "Switching to FW flashing state\n"); - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, arche_pdata->is_reset_act_hi); - gpio_set_value(arche_pdata->svc_sysboot_gpio, 1); + gpiod_set_value(arche_pdata->svc_sysboot, 1); usleep_range(100, 200); @@ -273,7 +271,7 @@ arche_platform_fw_flashing_seq(struct arche_platform_drvdata *arche_pdata) return ret; } - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, !arche_pdata->is_reset_act_hi); arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_FW_FLASHING); @@ -305,7 +303,7 @@ arche_platform_poweroff_seq(struct arche_platform_drvdata *arche_pdata) clk_disable_unprepare(arche_pdata->svc_ref_clk); /* As part of exit, put APB back in reset state */ - svc_reset_onoff(arche_pdata->svc_reset_gpio, + svc_reset_onoff(arche_pdata->svc_reset, arche_pdata->is_reset_act_hi); arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_OFF); @@ -435,6 +433,7 @@ static int arche_platform_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; int ret; + unsigned int flags; arche_pdata = devm_kzalloc(&pdev->dev, sizeof(*arche_pdata), GFP_KERNEL); @@ -444,61 +443,33 @@ static int arche_platform