[linux-sunxi] Re: [PATCH v7 04/10] mfd: axp20x: Add missing copyright notice

2016-01-13 Thread Carlo Caione
On Wed, Jan 13, 2016 at 4:30 AM, Chen-Yu Tsai <w...@csie.org> wrote:
> When the driver was merged, the original author did not include a proper
> copyright notice. This patch adds the notice, backdated to when the
> driver was merged.
>
> Cc: Carlo Caione <ca...@caione.org>
> Signed-off-by: Chen-Yu Tsai <w...@csie.org>
> ---

Acked-by: Carlo Caione <ca...@caione.org>

Thanks!

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Input: axp20x-pek: Add module alias

2015-08-03 Thread Carlo Caione
On Mon, Aug 3, 2015 at 9:48 AM, Chen-Yu Tsai w...@csie.org wrote:
 Add a proper module alias so the driver can be autoloaded when the
 parent axp20x mfd driver registers its cells.

 Signed-off-by: Chen-Yu Tsai w...@csie.org

Acked-by: Carlo Caione ca...@caione.org

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH] input: axp20x-pek: Fix reporting button state as inverted

2015-06-24 Thread Carlo Caione
On Wed, Jun 24, 2015 at 3:42 AM, Chen-Yu Tsai w...@csie.org wrote:
 On Tue, Jun 23, 2015 at 5:30 AM, Dmitry Torokhov
 dmitry.torok...@gmail.com wrote:
 On Sun, Jun 14, 2015 at 12:42:21PM +0200, Hans de Goede wrote:
 Currently we are reporting the button state as inverted on all boards with
 an axp209 pmic, tested on a ba10-tvbox, bananapi, bananapro, cubietruck and
 utoo-p66 tablet.

 The axp209 datasheet clearly states that the power button must be connected
 between the PWRON key and ground. Which means that on a press we will get
 a falling edge (dbf) irq not a rising one, and likewise on release we will
 get a rising edge (dbr) irq, not a falling one.

 This commit swaps the check for the 2 irqs fixing the inverted reporting of
 the power button state.

 Signed-off-by: Hans de Goede hdego...@redhat.com

 Carlo, Chen-Yu, could you please give this patch a spin and let us know
 if it works on your boards?

 I've not actually tested this patch on my boards, but I can confirm that
 the original code had the state inverted, by checking /proc/interrupts
 counters, before and after releasing the power button.

 Acked-by: Chen-Yu Tsai w...@csie.org

Same here (I don't have the board anymore)

Acked-by: Carlo Caione ca...@caione.org

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: 2015 SBC survey by Linux Foundation/LinuxGizmos

2015-06-16 Thread Carlo Caione
On Tue, Jun 16, 2015 at 10:21 AM, Michal Suchanek hramr...@gmail.com wrote:

 this one? http://openlinux.amlogic.com:8000/download/ARM/kernel/

 Maybe things have changed since then. When it was big news that
 Amlogic set up a developer community site I looked at it and I was
 required to register to access anything and had to sign a NDA to
 register.

You have to sign a NDA to access Android sources and (unfortunately)
datasheets. This sucks, I agree.
But at least you have free access to the kernel and u-boot sources (+
buildroot stuff and more).

 If they fixed the NDA thing then that's a good news. Some of the
 Amlogic chips look good spec-wise.

Yep :)

Sorry for the OT,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Lemon Pi on Indiegogo campaign,$35 ARM Quad-core A9 and Imagination PowerVR SGX544 open source board

2015-05-27 Thread Carlo Caione
On Wed, May 27, 2015 at 9:04 AM, Luc Verhaegen l...@skynet.be wrote:
 On Tue, May 26, 2015 at 08:06:13PM -0400, jonsm...@gmail.com wrote:
 On Tue, May 26, 2015 at 7:28 PM, Julian Calaby julian.cal...@gmail.com
 wrote:

  Hi,
 
  Stupid question: isn't this kinda off-topic for this list as the SoC on
  the LemonPi isn't an Allwinner part?
 

 Are there lists for these other Chinese vendors?  I haven't found one for
 Rockchip or AMLogic.

 As stated on http://linux-rockchip.info/mw/ it is on googlegroups as
 well: https://groups.google.com/forum/#!forum/linux-rockchip

 For amlogic, things are not as far advanced:
 http://linux-meson.com/doku.php#community

Well, things are going on actually. Really slowly since I'm basically
the only one working on it, but they are going on.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH v8 0/6] mfd: AXP20x: Add support for AXP202 and AXP209

2014-12-24 Thread Carlo Caione
On Tue, Dec 23, 2014 at 3:53 AM, Chen-Yu Tsai w...@csie.org wrote:
 Hi everyone,

Hi ChenYu,
Thank you very much for respinning this.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v7 0/6] mfd: AXP20x: Add support for AXP202 and AXP209

2014-10-22 Thread Carlo Caione
On Wed, Oct 22, 2014 at 09:59:29AM +0200, Maxime Ripard wrote:
 On Wed, Oct 22, 2014 at 08:28:42AM +0200, Bruno Prémont wrote:
  On Sun, 29 Jun 2014 20:23:51 +0200 Carlo Caione wrote:
   During the merging of v6 several patches were left out. This v7 comprises
   all the patches that are still pending.
  
  Any progress on this or reason why these are stuck?
 
 No one bothered resubmitting it.
 
 If you have some time to work on this, it would be great if you could
 pick up the work, if not, I'll do it.

Wow, I totally forgot about those patches. Sorry for that.
If you are willing to work on the patches go ahead, otherwise
I'll find a bit of time myself.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: GPL Violations round-up.

2014-09-22 Thread Carlo Caione
On Sun, Sep 21, 2014 at 10:02:15PM -0700, AndrewDB wrote:
 For what it's worth, I fully support Luc's actions to document Allwinner's 
 GPL violations.
 
 I also believe it is in Allwinner's interest to fully comply with the GPL 
 and that it's a pity that they don't understand this. How many (extremely 
 expensive) engineer-hours has this community generously contributed to 
 firmware/software development on Allwinner SOCs? I am positive that 
 Allwinner's present market share is in good part the result of this 
 community's work (although this assertion is impossible to prove), so why 
 not help this community by not having to reverse-engineer so many things?
 
 And finally, last but not least, I firmly believe that it is in the 
 interest of this community to have Allwinner fully comply with the GPL and 
 freely provide as much documentation as possible. So we should all stand 
 behind Luc and not be indifferent or worse, critical of his actions.
 
 Let me explain briefly where I am coming from:
 - First developer to have Linux booting on a dual-core Cortex-A9 AML8726MX 
 tablet.  Tried in vain to get any response from Amlogic about cooperation 
 with the Linux development community. Dropped development on this platform 
 because of total lack of support from Amlogic. Apparently in the last few 
 months they have been trying to reverse this situation, but I would say 
 it's too little, too late.

FWIW I'm working on mainlining amlogic SoCs and several patches have
been already submitted to LKML for Meson6 and Meson8 architectures. I'm
in contact with a couple of engineers in Amlogic and they seem willing
to help the community. They also promised to provide me with all the
documentation I need. We will see.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Compiling android kernel using android source files

2014-07-24 Thread Carlo Caione
On Thu, Jul 24, 2014 at 9:39 AM, Code Kipper codekip...@gmail.com wrote:

 Just a warning: This mailing list is for discussion and support of the
 upstream linux-sunxi kernel, not Android or the Lichee kernel.

I'd say linux is general, not only upstream but I agree that Android is OT.

 Is this really the case?according to the wiki
 http://linux-sunxi.org/Mailing_list this mailing list is for technical
 discussion pertaining to sunxi. It's not the first time that I feel someone
 has asked a relevant question only be get a reply like this from you.

Are you aware that this ml is called linux-sunxi right?

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Compiling android kernel using android source files

2014-07-24 Thread Carlo Caione
On Thu, Jul 24, 2014 at 11:02 AM, Code Kipper codekip...@gmail.com wrote:


 Are you aware that this ml is called linux-sunxi right?

 Yes and so is the website where a lot of this information is stored. Is
 Android really OT?, it's described here http://linux-sunxi.org/Android.

So what? This is a ml not a wiki, on the wiki you can find a lot of
related stuff.

 I would say that anything sunxi related is relevant here. If this was a
 purely kernel hangout, I would miss a lots of quite interesting
 information. It's not like this ml is flooded with questions.

The fact that there aren't that many questions doesn't allow people to
be OT and, please, consider also that the you can find something OT
interesting but a lot of other people are annoyed by it.
See, the problem is that often the posts in this ml are definitely OT
(see the Puneet B posts) so Julian is welcome to try to keep things on
topic.

FWIW I already proposed in the irc channel to create a ml specifically
for kernel development (on vger maybe?)

Aaas usual IMHO,

Ciao :)

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v7 3/6] input: misc: Add driver for AXP20x Power Enable Key

2014-06-30 Thread Carlo Caione
On Mon, Jun 30, 2014 at 11:47 AM, Mark Rutland mark.rutl...@arm.com wrote:
 +static struct platform_driver axp20x_pek_driver = {
 +   .probe  = axp20x_pek_probe,
 +   .remove = axp20x_pek_remove,
 +   .driver = {
 +   .name   = axp20x-pek,
 +   .owner  = THIS_MODULE,
 +   },
 +};
 +module_platform_driver(axp20x_pek_driver);

 So this requires platform data rather than a DTB? Or have I missed
 something?

It is not loaded by DTB but by the MFD core driver (axp20x). So I
assume this is still a platform device.

Regards,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v7 2/6] dt-bindings: add vendor-prefix for X-Powers

2014-06-29 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 46a311e..0d5a80c 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -140,6 +140,7 @@ voipac  Voipac Technologies s.r.o.
 winbond Winbond Electronics corp.
 wlfWolfson Microelectronics
 wm Wondermedia Technologies, Inc.
+x-powers   X-Powers
 xesExtreme Engineering Solutions (X-ES)
 xlnx   Xilinx
 zyxel  ZyXEL Communications Corp.
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v7 4/6] input: misc: Add ABI docs for AXP20x PEK

2014-06-29 Thread Carlo Caione
Add ABI entries for the PEK found on PMU X-Powers AXP202 and AXP209.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/ABI/testing/sysfs-driver-input-axp-pek | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek

diff --git a/Documentation/ABI/testing/sysfs-driver-input-axp-pek 
b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
new file mode 100644
index 000..080563b
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
@@ -0,0 +1,11 @@
+What:  /sys/class/input/input(x)/startup
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Startup time in us. Board is powered on if the button is pressed
+   for more than startup_time
+
+What:  /sys/class/input/input(x)/shutdown
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Shutdown time in us. Board is powered off if the button is 
pressed
+   for more than shutdown_time
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v7 1/6] mfd: AXP20x: Add bindings documentation

2014-06-29 Thread Carlo Caione
Bindings documentation for the AXP20x driver. In this file also
sub-nodes are documented.

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 93 
 1 file changed, 93 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt 
b/Documentation/devicetree/bindings/mfd/axp20x.txt
new file mode 100644
index 000..cc9e01b
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -0,0 +1,93 @@
+AXP202/AXP209 device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible: x-powers,axp202 or x-powers,axp209
+- reg: The I2C slave address for the AXP chip
+- interrupt-parent: The parent interrupt controller
+- interrupts: Interrupt specifiers for interrupt sources
+- interrupt-controller: axp20x has its own internal IRQs
+- #interrupt-cells: Should be set to 1
+- acin-supply: The input supply for LDO1
+- vin2-supply: The input supply for DCDC2
+- vin3-supply: The input supply for DCDC3
+- ldo24in-supply: The input supply for LDO2, LDO4
+- ldo3in-supply: The input supply for LDO3
+- ldo5in-supply: The input supply for LDO5
+
+- regulators: A node that houses a sub-node for each regulator. The regulators 
are
+ bound using their name as listed here: dcdc2, dcdc3, ldo1, ldo2,
+ ldo3, ldo4, ldo5.  The bindings details of individual regulator
+ device can be found in:
+ Documentation/devicetree/bindings/regulator/regulator.txt with
+ the exception of x-powers,dcdc-freq
+- x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
+ (range: 750-1875). Default: 1.5MHz
+
+Optional properties for DCDCs:
+- x-powers,dcdc-workmode: 1 for PWM mode, 0 for AUTO mode
+ Default: AUTO mode
+
+Example:
+
+axp209: pmic@34 {
+   compatible = x-powers,axp209;
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   acin-supply = axp_ipsout_reg;
+   vin2-supply = axp_ipsout_reg;
+   vin3-supply = axp_ipsout_reg;
+   ldo24in-supply = axp_ipsout_reg;
+   ldo3in-supply = axp_ipsout_reg;
+   ldo5in-supply = axp_ipsout_reg;
+
+   regulators {
+   x-powers,dcdc-freq = 1500;
+
+   axp_vcore_reg: dcdc2 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 2275000;
+   regulator-always-on;
+   };
+
+   axp_ddr_reg: dcdc3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   regulator-always-on;
+   };
+
+   axp_rtc_reg: ldo1 {
+   regulator-always-on;
+   };
+
+   axp_analog_reg: ldo2 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   regulator-always-on;
+   };
+
+   axp_pll_reg: ldo3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   };
+
+   axp_hdmi_reg: ldo4 {
+   regulator-min-microvolt = 125;
+   regulator-max-microvolt = 330;
+   };
+
+   axp_mic_reg: ldo5 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   };
+   };
+};
+
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v7 5/6] ARM: sunxi: Add AXP20x support in defconfig

2014-06-29 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/sunxi_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig
index 7209bfd..acf465f 100644
--- a/arch/arm/configs/sunxi_defconfig
+++ b/arch/arm/configs/sunxi_defconfig
@@ -54,6 +54,8 @@ CONFIG_STMMAC_ETH=y
 # CONFIG_INPUT_MOUSEDEV is not set
 # CONFIG_INPUT_KEYBOARD is not set
 # CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=8
@@ -77,6 +79,7 @@ CONFIG_SUNXI_WATCHDOG=y
 CONFIG_MFD_AXP20X=y
 CONFIG_REGULATOR_VIRTUAL_CONSUMER=y
 CONFIG_REGULATOR_GPIO=y
+CONFIG_REGULATOR_AXP20X=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_HCD_PLATFORM=y
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v7 0/6] mfd: AXP20x: Add support for AXP202 and AXP209

2014-06-29 Thread Carlo Caione
During the merging of v6 several patches were left out. This v7 comprises
all the patches that are still pending.

//--

AXP209 and AXP202 are the PMUs (Power Management Unit) used by A10, A13
and A20 SoCs and developed by X-Powers, a sister company of Allwinner.
AXP20x comprises an adaptive USB-Compatible PWM charger, 2 BUCK DC-DC
converters, 5 LDOs, multiple 12-bit ADCs of voltage, current and temperature
as well as 4 configurable GPIOs. 

This set of patches introduces the core driver and support for two different
subsystems:
- Regulators
- PEK (Power Enable Key)

Changes since v1:

- Added a new standalone patch for defconfig

- MFD core:
  * Removed axp,system-power-controller property

- Bindings documentation:
  * Corrected description for dcdc-workmode property
  * Removed unused axp20x-pek compatible

- Input misc PEK driver:
  * Fixed seconds in lower case

- Regulators subsystem:
  * Fixed axp20x_set_suspend_voltage()
  * Switched to using multi-bit control for regulators
  * When regulators node is not found driver doesn't quit
  * Driver is now using devm_regulator_register()
  * Added module_platform_driver() instead of subsys_initcall()

- DT:
  * Added new DTSI for AXP209
  * Added support for cubietruck and olinuxino-micro

Changes since v2:

- Added a new patch for multi_v7_defconfig to enable MFD core
  and subsystems

- DT:
  * Dropped axp,system-power-controller property from DTS
  * Moved compatible and interrupt-related properties from the
DTSI file to the DTS board files

- Regulators subsystem:
  * Deleted useless struct axp20x_regulators
  * Added a warning when out of specs values are used for the
dcdc frequency

- MFD core:
  * Fixed coding style
  * Removed IDs from device table for i2c

- Bindings documentation:
  * Several corrections and fixes

Changes since v3:

- Removed x-powers-axp209.dtsi file
- Rewritten bindings document

- MFD core:
  * Fixed casting
  * Better comments / documentation

- Input misc PEK driver:
  * Timings are now expressed in ms and the sysfs appies the
closest possible value
  * No more useless pretty-printing
  * Removed devm_request_threaded_irq in favour of
devm_request_any_context_irq
  * Moved from input attributes to platform device attributes

- Regulators subsystem:
  * Removed suspend mode (axp20x_set_suspend_voltage)
  * Added regulators input supply

- DT:
  * DTs doesn't include anymore the dtsi
  * Added input supplies for regulators

Changes since v4:

- Removed regulator patches already applied / acked by Mark Brown

- Input misc PEK driver:
  * Don't print anymore the us unit
  * Added cleanup for attributes when unbindind the device
  * Fixed error code returned when device_create_file() fails

- DT:
  * Enable all the regulators on at boot-time
  * Removed min and max microvolts for all the regulators but DCDC2
  * Moved the axp_ipsout regulator outside the MFD node
  
- MFD core:
  * The supply regulators are now specified in the MFD driver using
regulator_bulk_register_supply_alias() and the .parent_supplies
in the MFD cell

Changes since v5:
- Added ACKs
- Fixed compilation warning (reported by Hans De Goede)
- Vendor-prefixes are now sorted
- Removed DT patch


Carlo Caione (6):
  mfd: AXP20x: Add bindings documentation
  dt-bindings: add vendor-prefix for X-Powers
  input: misc: Add driver for AXP20x Power Enable Key
  input: misc: Add ABI docs for AXP20x PEK
  ARM: sunxi: Add AXP20x support in defconfig
  ARM: sunxi: Add AXP20x support multi_v7_defconfig

 .../ABI/testing/sysfs-driver-input-axp-pek |  11 +
 Documentation/devicetree/bindings/mfd/axp20x.txt   |  93 +++
 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 arch/arm/configs/multi_v7_defconfig|   3 +
 arch/arm/configs/sunxi_defconfig   |   3 +
 drivers/input/misc/Kconfig |  11 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/axp20x-pek.c| 281 +
 8 files changed, 404 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
 create mode 100644 drivers/input/misc/axp20x-pek.c

-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from

[linux-sunxi] [PATCH v7 6/6] ARM: sunxi: Add AXP20x support multi_v7_defconfig

2014-06-29 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/multi_v7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index be1a345..d79418e 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -159,6 +159,7 @@ CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_MOUSE_PS2_ELANTECH=y
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_MPU3050=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_SERIO_AMBAKMI=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
@@ -229,6 +230,7 @@ CONFIG_WATCHDOG=y
 CONFIG_ORION_WATCHDOG=y
 CONFIG_SUNXI_WATCHDOG=y
 CONFIG_MFD_AS3722=y
+CONFIG_MFD_AXP20X=y
 CONFIG_MFD_CROS_EC=y
 CONFIG_MFD_CROS_EC_SPI=y
 CONFIG_MFD_MAX8907=y
@@ -240,6 +242,7 @@ CONFIG_MFD_TPS65910=y
 CONFIG_REGULATOR_VIRTUAL_CONSUMER=y
 CONFIG_REGULATOR_AB8500=y
 CONFIG_REGULATOR_AS3722=y
+CONFIG_REGULATOR_AXP20X=y
 CONFIG_REGULATOR_GPIO=y
 CONFIG_REGULATOR_MAX8907=y
 CONFIG_REGULATOR_PALMAS=y
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v6 3/7] mfd: AXP20x: Add bindings documentation

2014-06-21 Thread Carlo Caione
On Wed, Jun 18, 2014 at 11:06 AM, Lee Jones lee.jo...@linaro.org wrote:
 On 19/05/2014 21:47, Carlo Caione wrote:
  Bindings documentation for the AXP20x driver. In this file also
  sub-nodes are documented.

 I think this patch has been forgotten (I didn't find it in linus' tree
 or linux-next tree).

 This patch-set became confusing.  Some of the patches were applied in
 v5 and were still submitted for v6.  I need Carlo to rebase on top of
 v3.16-rc1+ and re-submit with the Acks he's collected so far.

I'm confused too. At the time of the submission v6 was already the
patchset without the patches from v5 already applied and v6 already
contains all the ACKs I have collected (i.e. the input/misc driver has
been already ack-ed by Dmitry, yet it seems not merged).
So what exactly do you want me to resubmit? The whole v6 on top of v3.16-rc1+?

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v6 0/7] mfd: AXP20x: Add support for AXP202 and AXP209

2014-05-22 Thread Carlo Caione
On Wed, May 21, 2014 at 11:14 AM, Lee Jones lee.jo...@linaro.org wrote:
  This set of patches introduces the core driver and support for two 
  different
  subsystems:
- Regulators
 
   .../ABI/testing/sysfs-driver-input-axp-pek |  11 +
   Documentation/devicetree/bindings/mfd/axp20x.txt   |  93 +++
   .../devicetree/bindings/vendor-prefixes.txt|   1 +
   arch/arm/configs/multi_v7_defconfig|   3 +
   arch/arm/configs/sunxi_defconfig   |   4 +
   drivers/input/misc/Kconfig |  11 +
   drivers/input/misc/Makefile|   1 +
   drivers/input/misc/axp20x-pek.c| 281 
  +
   drivers/mfd/Kconfig|  12 +
   drivers/mfd/Makefile   |   1 +
   drivers/mfd/axp20x.c   | 258 
  +++
   include/linux/mfd/axp20x.h | 180 +
   12 files changed, 856 insertions(+)
 
  The regulator changes don't appear to be showing up in the diffstat or
  obviously in the series?

 Right. Cut-and-paste error.
 You have already applied the regulator patches so I didn't include
 them here (in theory I posted this series to be picked up by Lee).

 That's fine.  Just tell me which patches need to stay together and
 which are able to be applied through their respective subsystem trees
 separately.  Then, once I have all the Acks I can apply no problem.

Hi Lee,
I'd say #1 for the MFD tree, #4 for the input subsystem, #2 #3 and #5
are documentations, #6 and #7 defconfigs add-on.

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v6 0/7] mfd: AXP20x: Add support for AXP202 and AXP209

2014-05-21 Thread Carlo Caione
On Wed, May 21, 2014 at 12:23 AM, Mark Brown broo...@kernel.org wrote:
 On Mon, May 19, 2014 at 09:47:41PM +0200, Carlo Caione wrote:

 This set of patches introduces the core driver and support for two different
 subsystems:
   - Regulators

  .../ABI/testing/sysfs-driver-input-axp-pek |  11 +
  Documentation/devicetree/bindings/mfd/axp20x.txt   |  93 +++
  .../devicetree/bindings/vendor-prefixes.txt|   1 +
  arch/arm/configs/multi_v7_defconfig|   3 +
  arch/arm/configs/sunxi_defconfig   |   4 +
  drivers/input/misc/Kconfig |  11 +
  drivers/input/misc/Makefile|   1 +
  drivers/input/misc/axp20x-pek.c| 281 
 +
  drivers/mfd/Kconfig|  12 +
  drivers/mfd/Makefile   |   1 +
  drivers/mfd/axp20x.c   | 258 +++
  include/linux/mfd/axp20x.h | 180 +
  12 files changed, 856 insertions(+)

 The regulator changes don't appear to be showing up in the diffstat or
 obviously in the series?

Right. Cut-and-paste error.
You have already applied the regulator patches so I didn't include
them here (in theory I posted this series to be picked up by Lee).

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v5 4/8] input: misc: Add driver for AXP20x Power Enable Key

2014-05-19 Thread Carlo Caione
On Mon, May 19, 2014 at 7:57 AM, Dmitry Torokhov
dmitry.torok...@gmail.com wrote:
 On Fri, May 02, 2014 at 06:06:04PM -0700, Maxime Ripard wrote:
 On Thu, May 01, 2014 at 02:29:30PM +0200, Carlo Caione wrote:
  This patch add support for the Power Enable Key found on MFD AXP202 and
  AXP209. Besides the basic support for the button, the driver adds two
  entries in sysfs to configure the time delay for power on/off.
 
  Signed-off-by: Carlo Caione ca...@caione.org

 Acked-by: Maxime Ripard maxime.rip...@free-electrons.com

 Acked-by: Dmitry Torokhov dmitry.torok...@gmail.com

 How are we merging it? MFD tree?

No idea. Lee, can you help in merging it?
The only thing still  left out is the DT to be merged through Maxime
(I need to submit a v6 only for that).

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] regulator: AXP20x: fix wrong call to of_find_node_by_name

2014-05-19 Thread Carlo Caione
On Mon, May 19, 2014 at 10:25 AM, Boris BREZILLON
boris.brezil...@free-electrons.com wrote:
 The of_find_node_by_name function will search for a DT node named
 regulators after the provided np node, but will not ensure that this node
 is a child of np.
 This might result in retrieving a regulators node that is not related to
 the axp20x PMIC.

 Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
 ---

Acked-by: Carlo Caione ca...@caione.org

Thank you,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v6 1/7] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-05-19 Thread Carlo Caione
This patch introduces the preliminary support for PMICs X-Powers AXP202
and AXP209. The AXP209 and AXP202 are the PMUs (Power Management Unit)
used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company
of Allwinner.

The core enables support for two subsystems:
- PEK (Power Enable Key)
- Regulators

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Lee Jones lee.jo...@linaro.org
Acked-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 drivers/mfd/Kconfig|  12 +++
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/axp20x.c   | 258 +
 include/linux/mfd/axp20x.h | 180 +++
 4 files changed, 451 insertions(+)
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 include/linux/mfd/axp20x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 3383412..6c2a920 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -67,6 +67,18 @@ config MFD_BCM590XX
help
  Support for the BCM590xx PMUs from Broadcom
 
+config MFD_AXP20X
+   bool X-Powers AXP20X
+   select MFD_CORE
+   select REGMAP_I2C
+   select REGMAP_IRQ
+   depends on I2C=y
+   help
+ If you say Y here you get support for the X-Powers AXP202 and AXP209.
+ This driver include only the core APIs. You have to select individual
+ components like regulators or the PEK (Power Enable Key) under the
+ corresponding menus.
+
 config MFD_CROS_EC
tristate ChromeOS Embedded Controller
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 2851275..1efecf2 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -102,6 +102,7 @@ obj-$(CONFIG_PMIC_DA9052)   += da9052-irq.o
 obj-$(CONFIG_PMIC_DA9052)  += da9052-core.o
 obj-$(CONFIG_MFD_DA9052_SPI)   += da9052-spi.o
 obj-$(CONFIG_MFD_DA9052_I2C)   += da9052-i2c.o
+obj-$(CONFIG_MFD_AXP20X)   += axp20x.o
 
 obj-$(CONFIG_MFD_LP3943)   += lp3943.o
 obj-$(CONFIG_MFD_LP8788)   += lp8788.o lp8788-irq.o
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
new file mode 100644
index 000..5734f8c
--- /dev/null
+++ b/drivers/mfd/axp20x.c
@@ -0,0 +1,258 @@
+/*
+ * axp20x.c - MFD core driver for the X-Powers AXP202 and AXP209
+ *
+ * AXP20x comprises an adaptive USB-Compatible PWM charger, 2 BUCK DC-DC
+ * converters, 5 LDOs, multiple 12-bit ADCs of voltage, current and temperature
+ * as well as 4 configurable GPIOs.
+ *
+ * Author: Carlo Caione ca...@caione.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/pm_runtime.h
+#include linux/regmap.h
+#include linux/slab.h
+#include linux/regulator/consumer.h
+#include linux/mfd/axp20x.h
+#include linux/mfd/core.h
+#include linux/of_device.h
+#include linux/of_irq.h
+
+#define AXP20X_OFF 0x80
+
+static const struct regmap_range axp20x_writeable_ranges[] = {
+   regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
+   regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
+};
+
+static const struct regmap_range axp20x_volatile_ranges[] = {
+   regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
+};
+
+static const struct regmap_access_table axp20x_writeable_table = {
+   .yes_ranges = axp20x_writeable_ranges,
+   .n_yes_ranges   = ARRAY_SIZE(axp20x_writeable_ranges),
+};
+
+static const struct regmap_access_table axp20x_volatile_table = {
+   .yes_ranges = axp20x_volatile_ranges,
+   .n_yes_ranges   = ARRAY_SIZE(axp20x_volatile_ranges),
+};
+
+static struct resource axp20x_pek_resources[] = {
+   {
+   .name   = PEK_DBR,
+   .start  = AXP20X_IRQ_PEK_RIS_EDGE,
+   .end= AXP20X_IRQ_PEK_RIS_EDGE,
+   .flags  = IORESOURCE_IRQ,
+   }, {
+   .name   = PEK_DBF,
+   .start  = AXP20X_IRQ_PEK_FAL_EDGE,
+   .end= AXP20X_IRQ_PEK_FAL_EDGE,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static const struct regmap_config axp20x_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .wr_table   = axp20x_writeable_table,
+   .volatile_table = axp20x_volatile_table,
+   .max_register   = AXP20X_FG_RES,
+   .cache_type = REGCACHE_RBTREE,
+};
+
+#define AXP20X_IRQ(_irq, _off, _mask) \
+   [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
+
+static const struct regmap_irq axp20x_regmap_irqs[] = {
+   AXP20X_IRQ(ACIN_OVER_V, 0, 7),
+   AXP20X_IRQ(ACIN_PLUGIN, 0, 6),
+   AXP20X_IRQ(ACIN_REMOVAL,0, 5),
+   AXP20X_IRQ(VBUS_OVER_V, 0, 4),
+   AXP20X_IRQ(VBUS_PLUGIN, 0, 3

[linux-sunxi] [PATCH v6 7/7] ARM: sunxi: Add AXP20x support multi_v7_defconfig

2014-05-19 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/multi_v7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index d4e8a47..5aeea19 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -146,6 +146,7 @@ CONFIG_KEYBOARD_SPEAR=y
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_MOUSE_PS2_ELANTECH=y
 CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_INPUT_MPU3050=y
 CONFIG_SERIO_AMBAKMI=y
 CONFIG_SERIAL_8250=y
@@ -207,6 +208,7 @@ CONFIG_ARMADA_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_ORION_WATCHDOG=y
 CONFIG_MFD_AS3722=y
+CONFIG_MFD_AXP20X=y
 CONFIG_MFD_CROS_EC=y
 CONFIG_MFD_CROS_EC_SPI=y
 CONFIG_MFD_MAX8907=y
@@ -217,6 +219,7 @@ CONFIG_MFD_TPS65910=y
 CONFIG_REGULATOR_VIRTUAL_CONSUMER=y
 CONFIG_REGULATOR_AB8500=y
 CONFIG_REGULATOR_AS3722=y
+CONFIG_REGULATOR_AXP20X=y
 CONFIG_REGULATOR_GPIO=y
 CONFIG_REGULATOR_MAX8907=y
 CONFIG_REGULATOR_PALMAS=y
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v6 3/7] mfd: AXP20x: Add bindings documentation

2014-05-19 Thread Carlo Caione
Bindings documentation for the AXP20x driver. In this file also
sub-nodes are documented.

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 93 
 1 file changed, 93 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt 
b/Documentation/devicetree/bindings/mfd/axp20x.txt
new file mode 100644
index 000..cc9e01b
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -0,0 +1,93 @@
+AXP202/AXP209 device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible: x-powers,axp202 or x-powers,axp209
+- reg: The I2C slave address for the AXP chip
+- interrupt-parent: The parent interrupt controller
+- interrupts: Interrupt specifiers for interrupt sources
+- interrupt-controller: axp20x has its own internal IRQs
+- #interrupt-cells: Should be set to 1
+- acin-supply: The input supply for LDO1
+- vin2-supply: The input supply for DCDC2
+- vin3-supply: The input supply for DCDC3
+- ldo24in-supply: The input supply for LDO2, LDO4
+- ldo3in-supply: The input supply for LDO3
+- ldo5in-supply: The input supply for LDO5
+
+- regulators: A node that houses a sub-node for each regulator. The regulators 
are
+ bound using their name as listed here: dcdc2, dcdc3, ldo1, ldo2,
+ ldo3, ldo4, ldo5.  The bindings details of individual regulator
+ device can be found in:
+ Documentation/devicetree/bindings/regulator/regulator.txt with
+ the exception of x-powers,dcdc-freq
+- x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
+ (range: 750-1875). Default: 1.5MHz
+
+Optional properties for DCDCs:
+- x-powers,dcdc-workmode: 1 for PWM mode, 0 for AUTO mode
+ Default: AUTO mode
+
+Example:
+
+axp209: pmic@34 {
+   compatible = x-powers,axp209;
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   acin-supply = axp_ipsout_reg;
+   vin2-supply = axp_ipsout_reg;
+   vin3-supply = axp_ipsout_reg;
+   ldo24in-supply = axp_ipsout_reg;
+   ldo3in-supply = axp_ipsout_reg;
+   ldo5in-supply = axp_ipsout_reg;
+
+   regulators {
+   x-powers,dcdc-freq = 1500;
+
+   axp_vcore_reg: dcdc2 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 2275000;
+   regulator-always-on;
+   };
+
+   axp_ddr_reg: dcdc3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   regulator-always-on;
+   };
+
+   axp_rtc_reg: ldo1 {
+   regulator-always-on;
+   };
+
+   axp_analog_reg: ldo2 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   regulator-always-on;
+   };
+
+   axp_pll_reg: ldo3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   };
+
+   axp_hdmi_reg: ldo4 {
+   regulator-min-microvolt = 125;
+   regulator-max-microvolt = 330;
+   };
+
+   axp_mic_reg: ldo5 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   };
+   };
+};
+
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v6 5/7] input: misc: Add ABI docs for AXP20x PEK

2014-05-19 Thread Carlo Caione
Add ABI entries for the PEK found on PMU X-Powers AXP202 and AXP209.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/ABI/testing/sysfs-driver-input-axp-pek | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek

diff --git a/Documentation/ABI/testing/sysfs-driver-input-axp-pek 
b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
new file mode 100644
index 000..080563b
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
@@ -0,0 +1,11 @@
+What:  /sys/class/input/input(x)/startup
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Startup time in us. Board is powered on if the button is pressed
+   for more than startup_time
+
+What:  /sys/class/input/input(x)/shutdown
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Shutdown time in us. Board is powered off if the button is 
pressed
+   for more than shutdown_time
-- 
1.9.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v4 6/9] regulator: AXP20x: Add support for regulators subsystem

2014-05-16 Thread Carlo Caione
On Thu, May 15, 2014 at 8:03 PM, Boris BREZILLON
boris.brezil...@free-electrons.com wrote:
 Hello Carlo,

 On 11/04/2014 11:38, Carlo Caione wrote:
 AXP202 and AXP209 come with two synchronous step-down DC-DCs and five
 LDOs. This patch introduces basic support for those regulators.

 Signed-off-by: Carlo Caione ca...@caione.org
 ---
  drivers/regulator/Kconfig|   7 +
  drivers/regulator/Makefile   |   1 +
 [...]
 + if (!np)
 + return 0;
 +
 + regulators = of_find_node_by_name(np, regulators);

 I know I'm late, and this patch has already been applied, but shouldn't
 we use of_get_child_by_name instead of of_find_node_by_name.
 This might lead to wrong regulators node parsing if other regulators are
 defined in the DT after the axp20x node, because, AFAIK, this function
 searches for DT nodes defined after the specified np node, but not
 necessarely children of the np node.

Right. I'll prepare a fix. Feel free to submit a patch if you want.

Thank you,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 0/2] ARM: sunxi: Enable syscon for the system controller

2014-05-08 Thread Carlo Caione
On Thu, May 8, 2014 at 5:04 AM, Maxime Ripard
maxime.rip...@free-electrons.com wrote:

snip

   I believe this will be used for toggling the SRAM mappings. (Am I 
   right?)
 
  Definitely right.
 
   The second register toggles mappings for MUSB FIFO, EMAC, and a few of
   the other IP blocks we currently don't support.
 
  Not yet :)
 
  I wonder how other SoCs are actually handling this mapping between CPU
   DMA vs device of some SRAMs. Did you look at this?

 It seems quite a few grepping for syscon

 ??

 What do you mean?

 I wasn't really talking about syscon itself, just how other SoCs
 usually deals with this kind of remapping usually.

Ho, sorry. In general for what I have seen the drivers use syscon or
just map directly the register they need to use.
Probably there is something smarter that I'm not aware of.

   Moreover, the A31 doesn't seem to have this system controller, or at
   least this overlap.
 
  I admit that I didn't check the A31 manual but I trusted the wiki page
  at http://linux-sunxi.org/SRAM_Controller and
  http://linux-sunxi.org/A31/Memory_map
 
   There should be something similar, as does the A23. There is no overlap 
   AFAIK.
 
  I agree and will check also A23.
 
   And since on the A20, registers seem to have one usage only, so I
   guess we can just split this IP into several nodes, just like we did
   with the NMI.
  
   As stated above, the second register toggles SRAM mappings for at most
   4 SRAM blocks (for EMAC, MUSB, ACE, ISP).
  
   syscon would be a good way to share this register among the various 
   drivers.
   We do not toggle it in the current EMAC driver. The driver seems to 
   assume
   it is setup by the bootloader, and on the A20, it seems to be mapped to
   EMAC by default.
  
   The MUSB glue layer driver must toggle this.
 
  This is exactly why I wrote these patches. I started hacking /
  studying your MUSB driver and I think that using syscon is a better
  way to manage these registers instead of mapping them in several
  drivers also because most of the time a single register has to be used
  by multiple drivers (i.e. SRAM_CTL1_CFG is used for USB,  EMAC,
  etc...)
 
   I think this approach is better than all the individual drivers mapping
   the registers and toggling a single bit. In fact I did something similar
   when working on preliminary musb support.
 
  I agree with that.

 So do you suggest to drop the syscon idea waiting for the new soc
 framework?

 To be honest, I don't really know what to think of it. I'd need to see
 some code that uses this. Maybe we can just postpone the decision to
 whenever we will actually have some code submitted that make any use
 of this?

 If it's easier for you to keep the syscon at the moment for whateever
 driver you're working on before submitting it, I'm fine with it, but
 I'm not going to merge it right now either.

It's fine with me.
Thank you for your review,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 0/2] ARM: sunxi: Enable syscon for the system controller

2014-05-07 Thread Carlo Caione
On Wed, May 7, 2014 at 5:25 AM, Maxime Ripard
maxime.rip...@free-electrons.com wrote:
 On Tue, May 06, 2014 at 10:03:19AM +0200, Carlo Caione wrote:
 On Tue, May 6, 2014 at 8:36 AM, Chen-Yu Tsai w...@csie.org wrote:
  Hi,

 Hi,

  On Tue, May 6, 2014 at 6:55 AM, Maxime Ripard
  maxime.rip...@free-electrons.com wrote:
  On Sun, May 04, 2014 at 04:02:38PM +0200, Carlo Caione wrote:
  The so called system controller in Allwinner A20 and A31 SoCs is
  multi-purpose controller that tries to add misc functionality to one
  memory region.
  In these SoCs it controls the internal SRAM partitioning but it also
  includes registers for chip versioning and NMI control.
  This patch adds the proper nodes in the DTS files and enable the syscon
  in the defconfig files.
 
  Even though the system controller includes also register for managing the
  NMI controller, these register are not mapped in the syscon since they
  are directly used and mapped by the NMI controller itself.
 
  Hmmm, what exactly do you want to achieve with this?
 
  The NMI controller won't be able to use it, since it's initialized
  much earlier than syscon and regmap.

 This is what I meant with that phrase. NMI controller doesn't use the
 syscon but we can use it for several other drivers.

 I'm sorry, but I believe this should be more handled by the soon-to-be
 drivers/soc framework.

Oh, didn't know of this framework. Is it supposed to replace syscon?

 In fact the registers for NMI controller are excluded from the range
 of syscon registers.

 Then you are lying in the DT :)

Uhm, in DT I have:

reg = 0x01c0 0x27;

that is I'm mapping the first three registers: SRAM_CTRL_REG0,
SRAM_CTRL_REG1, VER_REG, leaving out the three register (from offset
0x30) of the NMI controller.
I'm not lying :)

  I believe this will be used for toggling the SRAM mappings. (Am I right?)

 Definitely right.

  The second register toggles mappings for MUSB FIFO, EMAC, and a few of
  the other IP blocks we currently don't support.

 Not yet :)

 I wonder how other SoCs are actually handling this mapping between CPU
  DMA vs device of some SRAMs. Did you look at this?

It seems quite a few grepping for syscon

  Moreover, the A31 doesn't seem to have this system controller, or at
  least this overlap.

 I admit that I didn't check the A31 manual but I trusted the wiki page
 at http://linux-sunxi.org/SRAM_Controller and
 http://linux-sunxi.org/A31/Memory_map

  There should be something similar, as does the A23. There is no overlap 
  AFAIK.

 I agree and will check also A23.

  And since on the A20, registers seem to have one usage only, so I
  guess we can just split this IP into several nodes, just like we did
  with the NMI.
 
  As stated above, the second register toggles SRAM mappings for at most
  4 SRAM blocks (for EMAC, MUSB, ACE, ISP).
 
  syscon would be a good way to share this register among the various 
  drivers.
  We do not toggle it in the current EMAC driver. The driver seems to assume
  it is setup by the bootloader, and on the A20, it seems to be mapped to
  EMAC by default.
 
  The MUSB glue layer driver must toggle this.

 This is exactly why I wrote these patches. I started hacking /
 studying your MUSB driver and I think that using syscon is a better
 way to manage these registers instead of mapping them in several
 drivers also because most of the time a single register has to be used
 by multiple drivers (i.e. SRAM_CTL1_CFG is used for USB,  EMAC,
 etc...)

  I think this approach is better than all the individual drivers mapping
  the registers and toggling a single bit. In fact I did something similar
  when working on preliminary musb support.

 I agree with that.

So do you suggest to drop the syscon idea waiting for the new soc framework?

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v5 8/8] ARM: sun7i/sun4i: dt: Add AXP209 support to various boards

2014-05-06 Thread Carlo Caione
On Tue, May 6, 2014 at 12:51 AM, Maxime Ripard
maxime.rip...@free-electrons.com wrote:
 On Sat, May 03, 2014 at 02:21:06PM +0200, Carlo Caione wrote:
 On Sat, May 3, 2014 at 3:09 AM, Maxime Ripard
 maxime.rip...@free-electrons.com wrote:
  Hi,
 
  On Thu, May 01, 2014 at 02:29:34PM +0200, Carlo Caione wrote:
  Signed-off-by: Hans de Goede hdego...@redhat.com
  Signed-off-by: Carlo Caione ca...@caione.org
  ---
   arch/arm/boot/dts/sun4i-a10-a1000.dts   | 58 
  ++
   arch/arm/boot/dts/sun4i-a10-cubieboard.dts  | 58 
  ++
   arch/arm/boot/dts/sun4i-a10-hackberry.dts   | 64 
  
   arch/arm/boot/dts/sun4i-a10-inet97fv2.dts   | 58 
  ++
   arch/arm/boot/dts/sun4i-a10-mini-xplus.dts  | 65 
  +
   arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dts  | 64 
  
   arch/arm/boot/dts/sun4i-a10-pcduino.dts | 58 
  ++
   arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 59 
  ++
   arch/arm/boot/dts/sun7i-a20-cubietruck.dts  | 59 
  ++
   arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 59 
  ++
   10 files changed, 602 insertions(+)
 
  diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts 
  b/arch/arm/boot/dts/sun4i-a10-a1000.dts
  index fa746aea..57d3fb4 100644
  --- a/arch/arm/boot/dts/sun4i-a10-a1000.dts
  +++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts
  @@ -88,6 +88,56 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
  +
  + axp209: pmic@34 {
  + compatible = x-powers,axp209;
  + reg = 0x34;
  + interrupts = 0;
  +
  + interrupt-controller;
  + #interrupt-cells = 1;
  +
  + acin-supply = reg_axp_ipsout;
  + vin2-supply = reg_axp_ipsout;
  + vin3-supply = reg_axp_ipsout;
  + ldo24in-supply = reg_axp_ipsout;
  + ldo3in-supply = reg_axp_ipsout;
  + ldo5in-supply = reg_axp_ipsout;
  +
  + regulators {
  + x-powers,dcdc-freq = 1500;
  +
  + axp_vcore_reg: dcdc2 {
  + regulator-min-microvolt = 
  70;
  + regulator-max-microvolt = 
  2275000;
  + regulator-always-on;
  + };
  +
  + axp_ddr_reg: dcdc3 {
  + regulator-always-on;
  + };
  +
  + axp_rtc_reg: ldo1 {
  + regulator-always-on;
  + };
  +
  + axp_analog_reg: ldo2 {
  + regulator-always-on;
  + };
  +
  + axp_pll_reg: ldo3 {
  + regulator-always-on;
  + };
  +
  + axp_hdmi_reg: ldo4 {
  + regulator-always-on;
  + };
  +
  + axp_mic_reg: ldo5 {
  + regulator-always-on;
 
  Do all these regulators need to be always on? It makes sense for the
  pll and vcore, but I don't get why the mic and hdmi regulators need
  this.

 I did this way because I don't have the schematics for all the board
 so I thought it was safer to leave all the regulators enabled

 Well, we have the schematics for most of these boards (at least all
 the cubie and olinuxinos).

 As far as the other boards are concerned, if we don't have that
 information, I'd say leave them alone until someone has access to
 these informations.

What do you mean exactly with leave them alone. The problem is that
if the regulator is not explicitly marked as always-on, it is disabled
at boot time, so I think that the most safe thing to do is leave them
on to avoid turning off something at boot time that could be
important.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 0/2] ARM: sunxi: Enable syscon for the system controller

2014-05-06 Thread Carlo Caione
On Tue, May 6, 2014 at 8:36 AM, Chen-Yu Tsai w...@csie.org wrote:
 Hi,

Hi,

 On Tue, May 6, 2014 at 6:55 AM, Maxime Ripard
 maxime.rip...@free-electrons.com wrote:
 On Sun, May 04, 2014 at 04:02:38PM +0200, Carlo Caione wrote:
 The so called system controller in Allwinner A20 and A31 SoCs is
 multi-purpose controller that tries to add misc functionality to one
 memory region.
 In these SoCs it controls the internal SRAM partitioning but it also
 includes registers for chip versioning and NMI control.
 This patch adds the proper nodes in the DTS files and enable the syscon
 in the defconfig files.

 Even though the system controller includes also register for managing the
 NMI controller, these register are not mapped in the syscon since they
 are directly used and mapped by the NMI controller itself.

 Hmmm, what exactly do you want to achieve with this?

 The NMI controller won't be able to use it, since it's initialized
 much earlier than syscon and regmap.

This is what I meant with that phrase. NMI controller doesn't use the
syscon but we can use it for several other drivers. In fact the
registers for NMI controller are excluded from the range of syscon
registers.

 I believe this will be used for toggling the SRAM mappings. (Am I right?)

Definitely right.

 The second register toggles mappings for MUSB FIFO, EMAC, and a few of
 the other IP blocks we currently don't support.

Not yet :)

 Moreover, the A31 doesn't seem to have this system controller, or at
 least this overlap.

I admit that I didn't check the A31 manual but I trusted the wiki page
at http://linux-sunxi.org/SRAM_Controller and
http://linux-sunxi.org/A31/Memory_map

 There should be something similar, as does the A23. There is no overlap AFAIK.

I agree and will check also A23.

 And since on the A20, registers seem to have one usage only, so I
 guess we can just split this IP into several nodes, just like we did
 with the NMI.

 As stated above, the second register toggles SRAM mappings for at most
 4 SRAM blocks (for EMAC, MUSB, ACE, ISP).

 syscon would be a good way to share this register among the various drivers.
 We do not toggle it in the current EMAC driver. The driver seems to assume
 it is setup by the bootloader, and on the A20, it seems to be mapped to
 EMAC by default.

 The MUSB glue layer driver must toggle this.

This is exactly why I wrote these patches. I started hacking /
studying your MUSB driver and I think that using syscon is a better
way to manage these registers instead of mapping them in several
drivers also because most of the time a single register has to be used
by multiple drivers (i.e. SRAM_CTL1_CFG is used for USB,  EMAC,
etc...)

 I think this approach is better than all the individual drivers mapping
 the registers and toggling a single bit. In fact I did something similar
 when working on preliminary musb support.

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH 0/2] ARM: sunxi: Enable syscon for the system controller

2014-05-04 Thread Carlo Caione
The so called system controller in Allwinner A20 and A31 SoCs is
multi-purpose controller that tries to add misc functionality to one
memory region.
In these SoCs it controls the internal SRAM partitioning but it also
includes registers for chip versioning and NMI control.
This patch adds the proper nodes in the DTS files and enable the syscon
in the defconfig files.

Even though the system controller includes also register for managing the
NMI controller, these register are not mapped in the syscon since they
are directly used and mapped by the NMI controller itself.

Carlo Caione (2):
  ARM: sunxi: dts: Enable syscon in DTSI
  ARM: sunxi: Add syscon support in defconfig

 arch/arm/boot/dts/sun6i-a31.dtsi| 5 +
 arch/arm/boot/dts/sun7i-a20.dtsi| 5 +
 arch/arm/configs/multi_v7_defconfig | 1 +
 arch/arm/configs/sunxi_defconfig| 1 +
 4 files changed, 12 insertions(+)

-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH 1/2] ARM: sunxi: dts: Enable syscon in DTSI

2014-05-04 Thread Carlo Caione
This patch adds the proper nodes in the DTSI files for Allwinner
A20 and A31.

Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/boot/dts/sun6i-a31.dtsi | 5 +
 arch/arm/boot/dts/sun7i-a20.dtsi | 5 +
 2 files changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index bc46814..775e64a 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -237,6 +237,11 @@
#size-cells = 1;
ranges;
 
+   syscon: syscon@01c0 {
+   compatible = syscon;
+   reg = 0x01c0 0x27;
+   };
+
nmi_intc: interrupt-controller@01f00c0c {
compatible = allwinner,sun6i-a31-sc-nmi;
interrupt-controller;
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 88171f4..14f8933 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -401,6 +401,11 @@
#size-cells = 1;
ranges;
 
+   syscon: syscon@01c0 {
+   compatible = syscon;
+   reg = 0x01c0 0x27;
+   };
+
nmi_intc: interrupt-controller@01c00030 {
compatible = allwinner,sun7i-a20-sc-nmi;
interrupt-controller;
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH 2/2] ARM: sunxi: Add syscon support in defconfig

2014-05-04 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 arch/arm/configs/sunxi_defconfig| 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index d4e8a47..d04fef5 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -343,3 +343,4 @@ CONFIG_DEBUG_FS=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_LOCKUP_DETECTOR=y
 CONFIG_CRYPTO_DEV_TEGRA_AES=y
+CONFIG_MFD_SYSCON=y
diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig
index b5df4a5..2ee8838 100644
--- a/arch/arm/configs/sunxi_defconfig
+++ b/arch/arm/configs/sunxi_defconfig
@@ -69,3 +69,4 @@ CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
 CONFIG_NLS=y
 CONFIG_PRINTK_TIME=y
+CONFIG_MFD_SYSCON=y
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v5 8/8] ARM: sun7i/sun4i: dt: Add AXP209 support to various boards

2014-05-03 Thread Carlo Caione
On Sat, May 3, 2014 at 3:09 AM, Maxime Ripard
maxime.rip...@free-electrons.com wrote:
 Hi,

 On Thu, May 01, 2014 at 02:29:34PM +0200, Carlo Caione wrote:
 Signed-off-by: Hans de Goede hdego...@redhat.com
 Signed-off-by: Carlo Caione ca...@caione.org
 ---
  arch/arm/boot/dts/sun4i-a10-a1000.dts   | 58 ++
  arch/arm/boot/dts/sun4i-a10-cubieboard.dts  | 58 ++
  arch/arm/boot/dts/sun4i-a10-hackberry.dts   | 64 
 
  arch/arm/boot/dts/sun4i-a10-inet97fv2.dts   | 58 ++
  arch/arm/boot/dts/sun4i-a10-mini-xplus.dts  | 65 
 +
  arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dts  | 64 
 
  arch/arm/boot/dts/sun4i-a10-pcduino.dts | 58 ++
  arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 59 ++
  arch/arm/boot/dts/sun7i-a20-cubietruck.dts  | 59 ++
  arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 59 ++
  10 files changed, 602 insertions(+)

 diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts 
 b/arch/arm/boot/dts/sun4i-a10-a1000.dts
 index fa746aea..57d3fb4 100644
 --- a/arch/arm/boot/dts/sun4i-a10-a1000.dts
 +++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts
 @@ -88,6 +88,56 @@
   pinctrl-names = default;
   pinctrl-0 = i2c0_pins_a;
   status = okay;
 +
 + axp209: pmic@34 {
 + compatible = x-powers,axp209;
 + reg = 0x34;
 + interrupts = 0;
 +
 + interrupt-controller;
 + #interrupt-cells = 1;
 +
 + acin-supply = reg_axp_ipsout;
 + vin2-supply = reg_axp_ipsout;
 + vin3-supply = reg_axp_ipsout;
 + ldo24in-supply = reg_axp_ipsout;
 + ldo3in-supply = reg_axp_ipsout;
 + ldo5in-supply = reg_axp_ipsout;
 +
 + regulators {
 + x-powers,dcdc-freq = 1500;
 +
 + axp_vcore_reg: dcdc2 {
 + regulator-min-microvolt = 
 70;
 + regulator-max-microvolt = 
 2275000;
 + regulator-always-on;
 + };
 +
 + axp_ddr_reg: dcdc3 {
 + regulator-always-on;
 + };
 +
 + axp_rtc_reg: ldo1 {
 + regulator-always-on;
 + };
 +
 + axp_analog_reg: ldo2 {
 + regulator-always-on;
 + };
 +
 + axp_pll_reg: ldo3 {
 + regulator-always-on;
 + };
 +
 + axp_hdmi_reg: ldo4 {
 + regulator-always-on;
 + };
 +
 + axp_mic_reg: ldo5 {
 + regulator-always-on;

 Do all these regulators need to be always on? It makes sense for the
 pll and vcore, but I don't get why the mic and hdmi regulators need
 this.

I did this way because I don't have the schematics for all the board
so I thought it was safer to leave all the regulators enabled

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v5 2/8] dt-bindings: add vendor-prefix for X-Powers

2014-05-02 Thread Carlo Caione
On Fri, May 2, 2014 at 7:24 AM, Michal Simek mon...@monstr.eu wrote:

 On 05/01/2014 02:29 PM, Carlo Caione wrote:
  Signed-off-by: Carlo Caione ca...@caione.org
  ---
   Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
   1 file changed, 1 insertion(+)
 
  diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt
 b/Documentation/devicetree/bindings/vendor-prefixes.txt
  index abc3080..792cf56 100644
  --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
  +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
  @@ -135,3 +135,4 @@ wmWondermedia Technologies, Inc.
   xes  Extreme Engineering Solutions (X-ES)
   xlnx Xilinx
   zyxelZyXEL Communications Corp.
  +x-powers X-Powers
 

 Keep list sorted.


Fooled by rebasing on master :(
I'll sort it, thanks.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v5 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-05-02 Thread Carlo Caione
On Fri, May 2, 2014 at 10:15 AM, Lee Jones lee.jo...@linaro.org wrote:
 This patch introduces the preliminary support for PMICs X-Powers AXP202
 and AXP209. The AXP209 and AXP202 are the PMUs (Power Management Unit)
 used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company
 of Allwinner.

 The core enables support for two subsystems:
 - PEK (Power Enable Key)
 - Regulators

 Signed-off-by: Carlo Caione ca...@caione.org
 Acked-by: Lee Jones lee.jo...@linaro.org
 ---

 I guess I can just apply this and expect not to see any adverse
 symptoms?

It has been tested with a sun7i/cubieboard2 with to adverse symptoms.
It's not core stuff so I guess you could apply it.

Thank you,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v5 0/8] mfd: AXP20x: Add support for AXP202 and AXP209

2014-05-01 Thread Carlo Caione
AXP209 and AXP202 are the PMUs (Power Management Unit) used by A10, A13
and A20 SoCs and developed by X-Powers, a sister company of Allwinner.
AXP20x comprises an adaptive USB-Compatible PWM charger, 2 BUCK DC-DC
converters, 5 LDOs, multiple 12-bit ADCs of voltage, current and temperature
as well as 4 configurable GPIOs. 

This set of patches introduces the core driver and support for two different
subsystems:
- Regulators
- PEK (Power Enable Key)

Changes since v1:

- Added a new standalone patch for defconfig

- MFD core:
  * Removed axp,system-power-controller property

- Bindings documentation:
  * Corrected description for dcdc-workmode property
  * Removed unused axp20x-pek compatible

- Input misc PEK driver:
  * Fixed seconds in lower case

- Regulators subsystem:
  * Fixed axp20x_set_suspend_voltage()
  * Switched to using multi-bit control for regulators
  * When regulators node is not found driver doesn't quit
  * Driver is now using devm_regulator_register()
  * Added module_platform_driver() instead of subsys_initcall()

- DT:
  * Added new DTSI for AXP209
  * Added support for cubietruck and olinuxino-micro

Changes since v2:

- Added a new patch for multi_v7_defconfig to enable MFD core
  and subsystems

- DT:
  * Dropped axp,system-power-controller property from DTS
  * Moved compatible and interrupt-related properties from the
DTSI file to the DTS board files

- Regulators subsystem:
  * Deleted useless struct axp20x_regulators
  * Added a warning when out of specs values are used for the
dcdc frequency

- MFD core:
  * Fixed coding style
  * Removed IDs from device table for i2c

- Bindings documentation:
  * Several corrections and fixes

Changes since v3:

- Removed x-powers-axp209.dtsi file
- Rewritten bindings document

- MFD core:
  * Fixed casting
  * Better comments / documentation

- Input misc PEK driver:
  * Timings are now expressed in ms and the sysfs appies the
closest possible value
  * No more useless pretty-printing
  * Removed devm_request_threaded_irq in favour of
devm_request_any_context_irq
  * Moved from input attributes to platform device attributes

- Regulators subsystem:
  * Removed suspend mode (axp20x_set_suspend_voltage)
  * Added regulators input supply

- DT:
  * DTs doesn't include anymore the dtsi
  * Added input supplies for regulators

Changes since v4:

- Removed regulator patches already applied / acked by Mark Brown

- Input misc PEK driver:
  * Don't print anymore the us unit
  * Added cleanup for attributes when unbindind the device
  * Fixed error code returned when device_create_file() fails

- DT:
  * Enable all the regulators on at boot-time
  * Removed min and max microvolts for all the regulators but DCDC2
  * Moved the axp_ipsout regulator outside the MFD node
  
- MFD core:
  * The supply regulators are now specified in the MFD driver using
regulator_bulk_register_supply_alias() and the .parent_supplies
in the MFD cell

Carlo Caione (8):
  mfd: AXP20x: Add mfd driver for AXP20x PMIC
  dt-bindings: add vendor-prefix for X-Powers
  mfd: AXP20x: Add bindings documentation
  input: misc: Add driver for AXP20x Power Enable Key
  input: misc: Add ABI docs for AXP20x PEK
  ARM: sunxi: Add AXP20x support in defconfig
  ARM: sunxi: Add AXP20x support multi_v7_defconfig
  ARM: sun7i/sun4i: dt: Add AXP209 support to various boards

 .../ABI/testing/sysfs-driver-input-axp-pek |  11 +
 Documentation/devicetree/bindings/mfd/axp20x.txt   |  93 +++
 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 arch/arm/boot/dts/sun4i-a10-a1000.dts  |  58 +
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts |  58 +
 arch/arm/boot/dts/sun4i-a10-hackberry.dts  |  64 +
 arch/arm/boot/dts/sun4i-a10-inet97fv2.dts  |  58 +
 arch/arm/boot/dts/sun4i-a10-mini-xplus.dts |  65 +
 arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dts |  64 +
 arch/arm/boot/dts/sun4i-a10-pcduino.dts|  58 +
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts|  59 +
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts |  59 +
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts|  59 +
 arch/arm/configs/multi_v7_defconfig|   3 +
 arch/arm/configs/sunxi_defconfig   |   4 +
 drivers/input/misc/Kconfig |  11 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/axp20x-pek.c

[linux-sunxi] [PATCH v5 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-05-01 Thread Carlo Caione
This patch introduces the preliminary support for PMICs X-Powers AXP202
and AXP209. The AXP209 and AXP202 are the PMUs (Power Management Unit)
used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company
of Allwinner.

The core enables support for two subsystems:
- PEK (Power Enable Key)
- Regulators

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Lee Jones lee.jo...@linaro.org
---

There is still a small bug in the MFD core that causes hitting the

WARN_ON(!list_empty(dev-devres_head));

in linux/drivers/base/dd.c#L272 when using the
regulator_bulk_register_supply_alias(). The warning complains that the MFD
core is trying to probe a device that has devres attached.
Charles Keepax is looking for this problem and a patch should be submitted
soon, see http://www.spinics.net/lists/linux-input/msg31099.html and
following

 drivers/mfd/Kconfig|  12 +++
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/axp20x.c   | 258 +
 include/linux/mfd/axp20x.h | 180 +++
 4 files changed, 451 insertions(+)
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 include/linux/mfd/axp20x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 3383412..6c2a920 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -67,6 +67,18 @@ config MFD_BCM590XX
help
  Support for the BCM590xx PMUs from Broadcom
 
+config MFD_AXP20X
+   bool X-Powers AXP20X
+   select MFD_CORE
+   select REGMAP_I2C
+   select REGMAP_IRQ
+   depends on I2C=y
+   help
+ If you say Y here you get support for the X-Powers AXP202 and AXP209.
+ This driver include only the core APIs. You have to select individual
+ components like regulators or the PEK (Power Enable Key) under the
+ corresponding menus.
+
 config MFD_CROS_EC
tristate ChromeOS Embedded Controller
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 2851275..1efecf2 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -102,6 +102,7 @@ obj-$(CONFIG_PMIC_DA9052)   += da9052-irq.o
 obj-$(CONFIG_PMIC_DA9052)  += da9052-core.o
 obj-$(CONFIG_MFD_DA9052_SPI)   += da9052-spi.o
 obj-$(CONFIG_MFD_DA9052_I2C)   += da9052-i2c.o
+obj-$(CONFIG_MFD_AXP20X)   += axp20x.o
 
 obj-$(CONFIG_MFD_LP3943)   += lp3943.o
 obj-$(CONFIG_MFD_LP8788)   += lp8788.o lp8788-irq.o
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
new file mode 100644
index 000..dee6539
--- /dev/null
+++ b/drivers/mfd/axp20x.c
@@ -0,0 +1,258 @@
+/*
+ * axp20x.c - MFD core driver for the X-Powers AXP202 and AXP209
+ *
+ * AXP20x comprises an adaptive USB-Compatible PWM charger, 2 BUCK DC-DC
+ * converters, 5 LDOs, multiple 12-bit ADCs of voltage, current and temperature
+ * as well as 4 configurable GPIOs.
+ *
+ * Author: Carlo Caione ca...@caione.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/pm_runtime.h
+#include linux/regmap.h
+#include linux/slab.h
+#include linux/regulator/consumer.h
+#include linux/mfd/axp20x.h
+#include linux/mfd/core.h
+#include linux/of_device.h
+#include linux/of_irq.h
+
+#define AXP20X_OFF 0x80
+
+static const struct regmap_range axp20x_writeable_ranges[] = {
+   regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
+   regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
+};
+
+static const struct regmap_range axp20x_volatile_ranges[] = {
+   regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
+};
+
+static const struct regmap_access_table axp20x_writeable_table = {
+   .yes_ranges = axp20x_writeable_ranges,
+   .n_yes_ranges   = ARRAY_SIZE(axp20x_writeable_ranges),
+};
+
+static const struct regmap_access_table axp20x_volatile_table = {
+   .yes_ranges = axp20x_volatile_ranges,
+   .n_yes_ranges   = ARRAY_SIZE(axp20x_volatile_ranges),
+};
+
+static struct resource axp20x_pek_resources[] = {
+   {
+   .name   = PEK_DBR,
+   .start  = AXP20X_IRQ_PEK_RIS_EDGE,
+   .end= AXP20X_IRQ_PEK_RIS_EDGE,
+   .flags  = IORESOURCE_IRQ,
+   }, {
+   .name   = PEK_DBF,
+   .start  = AXP20X_IRQ_PEK_FAL_EDGE,
+   .end= AXP20X_IRQ_PEK_FAL_EDGE,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static const struct regmap_config axp20x_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .wr_table   = axp20x_writeable_table,
+   .volatile_table = axp20x_volatile_table,
+   .max_register   = AXP20X_FG_RES,
+   .cache_type = REGCACHE_RBTREE,
+};
+
+#define AXP20X_IRQ(_irq, _off

[linux-sunxi] [PATCH v5 3/8] mfd: AXP20x: Add bindings documentation

2014-05-01 Thread Carlo Caione
Bindings documentation for the AXP20x driver. In this file also
sub-nodes are documented.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 93 
 1 file changed, 93 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt 
b/Documentation/devicetree/bindings/mfd/axp20x.txt
new file mode 100644
index 000..cc9e01b
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -0,0 +1,93 @@
+AXP202/AXP209 device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible: x-powers,axp202 or x-powers,axp209
+- reg: The I2C slave address for the AXP chip
+- interrupt-parent: The parent interrupt controller
+- interrupts: Interrupt specifiers for interrupt sources
+- interrupt-controller: axp20x has its own internal IRQs
+- #interrupt-cells: Should be set to 1
+- acin-supply: The input supply for LDO1
+- vin2-supply: The input supply for DCDC2
+- vin3-supply: The input supply for DCDC3
+- ldo24in-supply: The input supply for LDO2, LDO4
+- ldo3in-supply: The input supply for LDO3
+- ldo5in-supply: The input supply for LDO5
+
+- regulators: A node that houses a sub-node for each regulator. The regulators 
are
+ bound using their name as listed here: dcdc2, dcdc3, ldo1, ldo2,
+ ldo3, ldo4, ldo5.  The bindings details of individual regulator
+ device can be found in:
+ Documentation/devicetree/bindings/regulator/regulator.txt with
+ the exception of x-powers,dcdc-freq
+- x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
+ (range: 750-1875). Default: 1.5MHz
+
+Optional properties for DCDCs:
+- x-powers,dcdc-workmode: 1 for PWM mode, 0 for AUTO mode
+ Default: AUTO mode
+
+Example:
+
+axp209: pmic@34 {
+   compatible = x-powers,axp209;
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   acin-supply = axp_ipsout_reg;
+   vin2-supply = axp_ipsout_reg;
+   vin3-supply = axp_ipsout_reg;
+   ldo24in-supply = axp_ipsout_reg;
+   ldo3in-supply = axp_ipsout_reg;
+   ldo5in-supply = axp_ipsout_reg;
+
+   regulators {
+   x-powers,dcdc-freq = 1500;
+
+   axp_vcore_reg: dcdc2 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 2275000;
+   regulator-always-on;
+   };
+
+   axp_ddr_reg: dcdc3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   regulator-always-on;
+   };
+
+   axp_rtc_reg: ldo1 {
+   regulator-always-on;
+   };
+
+   axp_analog_reg: ldo2 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   regulator-always-on;
+   };
+
+   axp_pll_reg: ldo3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   };
+
+   axp_hdmi_reg: ldo4 {
+   regulator-min-microvolt = 125;
+   regulator-max-microvolt = 330;
+   };
+
+   axp_mic_reg: ldo5 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   };
+   };
+};
+
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v5 2/8] dt-bindings: add vendor-prefix for X-Powers

2014-05-01 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index abc3080..792cf56 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -135,3 +135,4 @@ wm  Wondermedia Technologies, Inc.
 xesExtreme Engineering Solutions (X-ES)
 xlnx   Xilinx
 zyxel  ZyXEL Communications Corp.
+x-powers   X-Powers
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v5 4/8] input: misc: Add driver for AXP20x Power Enable Key

2014-05-01 Thread Carlo Caione
This patch add support for the Power Enable Key found on MFD AXP202 and
AXP209. Besides the basic support for the button, the driver adds two
entries in sysfs to configure the time delay for power on/off.

Signed-off-by: Carlo Caione ca...@caione.org
---
 drivers/input/misc/Kconfig  |  11 ++
 drivers/input/misc/Makefile |   1 +
 drivers/input/misc/axp20x-pek.c | 281 
 3 files changed, 293 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5928ea7..f4c3177 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -393,6 +393,17 @@ config INPUT_RETU_PWRBUTTON
  To compile this driver as a module, choose M here. The module will
  be called retu-pwrbutton.
 
+config INPUT_AXP20X_PEK
+   tristate X-Powers AXP20X power button driver
+   depends on MFD_AXP20X
+   help
+ Say Y here if you want to enable power key reporting via the
+ AXP20X PMIC.
+
+ To compile this driver as a module, choose M here. The module will
+ be called axp20x-pek.
+
+
 config INPUT_TWL4030_PWRBUTTON
tristate TWL4030 Power button Driver
depends on TWL4030_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 4955ad3..a25ad18 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
+obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
new file mode 100644
index 000..0fba252
--- /dev/null
+++ b/drivers/input/misc/axp20x-pek.c
@@ -0,0 +1,281 @@
+/*
+ * axp20x power button driver.
+ *
+ * Copyright (C) 2013 Carlo Caione ca...@caione.org
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/errno.h
+#include linux/irq.h
+#include linux/init.h
+#include linux/input.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/mfd/axp20x.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/slab.h
+
+#define AXP20X_PEK_STARTUP_MASK(0xc0)
+#define AXP20X_PEK_SHUTDOWN_MASK   (0x03)
+
+struct axp20x_pek {
+   struct axp20x_dev *axp20x;
+   struct input_dev *input;
+   int irq_dbr;
+   int irq_dbf;
+};
+
+struct axp20x_time {
+   unsigned int time;
+   unsigned int idx;
+};
+
+static const struct axp20x_time startup_time[] = {
+   { .time = 128,  .idx = 0 },
+   { .time = 1000, .idx = 2 },
+   { .time = 3000, .idx = 1 },
+   { .time = 2000, .idx = 3 },
+};
+
+static const struct axp20x_time shutdown_time[] = {
+   { .time = 4000,  .idx = 0 },
+   { .time = 6000,  .idx = 1 },
+   { .time = 8000,  .idx = 2 },
+   { .time = 1, .idx = 3 },
+};
+
+struct axp20x_pek_ext_attr {
+   const struct axp20x_time *p_time;
+   unsigned int mask;
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = {
+   .p_time = startup_time,
+   .mask   = AXP20X_PEK_STARTUP_MASK,
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = {
+   .p_time = shutdown_time,
+   .mask   = AXP20X_PEK_SHUTDOWN_MASK,
+};
+
+static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute 
*attr)
+{
+   return container_of(attr, struct dev_ext_attribute, attr)-var;
+}
+
+static ssize_t axp20x_show_ext_attr(struct device *dev, struct 
device_attribute *attr,
+   char *buf)
+{
+   struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+   struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
+   unsigned int val;
+   int ret, i;
+
+   ret = regmap_read(axp20x_pek-axp20x-regmap, AXP20X_PEK_KEY, val);
+   if (ret != 0)
+   return ret;
+
+   val = axp20x_ea-mask;
+   val = ffs(axp20x_ea-mask) - 1;
+
+   for (i = 0; i  4; i++)
+   if (val == axp20x_ea-p_time[i].idx)
+   val = axp20x_ea-p_time[i].time;
+
+   return sprintf(buf, %u\n, val);
+}
+
+static ssize_t axp20x_store_ext_attr(struct device *dev

[linux-sunxi] [PATCH v5 6/8] ARM: sunxi: Add AXP20x support in defconfig

2014-05-01 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/sunxi_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig
index b5df4a5..6e305da 100644
--- a/arch/arm/configs/sunxi_defconfig
+++ b/arch/arm/configs/sunxi_defconfig
@@ -40,6 +40,8 @@ CONFIG_SUN4I_EMAC=y
 # CONFIG_NET_VENDOR_STMICRO is not set
 # CONFIG_NET_VENDOR_WIZNET is not set
 # CONFIG_WLAN is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=8
@@ -55,6 +57,7 @@ CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
 CONFIG_SUNXI_WATCHDOG=y
+CONFIG_MFD_AXP20X=y
 # CONFIG_USB_SUPPORT is not set
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
@@ -69,3 +72,4 @@ CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
 CONFIG_NLS=y
 CONFIG_PRINTK_TIME=y
+CONFIG_REGULATOR_AXP20X=y
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v5 7/8] ARM: sunxi: Add AXP20x support multi_v7_defconfig

2014-05-01 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/multi_v7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index d4e8a47..5aeea19 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -146,6 +146,7 @@ CONFIG_KEYBOARD_SPEAR=y
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_MOUSE_PS2_ELANTECH=y
 CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_INPUT_MPU3050=y
 CONFIG_SERIO_AMBAKMI=y
 CONFIG_SERIAL_8250=y
@@ -207,6 +208,7 @@ CONFIG_ARMADA_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_ORION_WATCHDOG=y
 CONFIG_MFD_AS3722=y
+CONFIG_MFD_AXP20X=y
 CONFIG_MFD_CROS_EC=y
 CONFIG_MFD_CROS_EC_SPI=y
 CONFIG_MFD_MAX8907=y
@@ -217,6 +219,7 @@ CONFIG_MFD_TPS65910=y
 CONFIG_REGULATOR_VIRTUAL_CONSUMER=y
 CONFIG_REGULATOR_AB8500=y
 CONFIG_REGULATOR_AS3722=y
+CONFIG_REGULATOR_AXP20X=y
 CONFIG_REGULATOR_GPIO=y
 CONFIG_REGULATOR_MAX8907=y
 CONFIG_REGULATOR_PALMAS=y
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v5 5/8] input: misc: Add ABI docs for AXP20x PEK

2014-05-01 Thread Carlo Caione
Add ABI entries for the PEK found on PMU X-Powers AXP202 and AXP209.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/ABI/testing/sysfs-driver-input-axp-pek | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek

diff --git a/Documentation/ABI/testing/sysfs-driver-input-axp-pek 
b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
new file mode 100644
index 000..080563b
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
@@ -0,0 +1,11 @@
+What:  /sys/class/input/input(x)/startup
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Startup time in us. Board is powered on if the button is pressed
+   for more than startup_time
+
+What:  /sys/class/input/input(x)/shutdown
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Shutdown time in us. Board is powered off if the button is 
pressed
+   for more than shutdown_time
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v5 8/8] ARM: sun7i/sun4i: dt: Add AXP209 support to various boards

2014-05-01 Thread Carlo Caione
Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/boot/dts/sun4i-a10-a1000.dts   | 58 ++
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts  | 58 ++
 arch/arm/boot/dts/sun4i-a10-hackberry.dts   | 64 
 arch/arm/boot/dts/sun4i-a10-inet97fv2.dts   | 58 ++
 arch/arm/boot/dts/sun4i-a10-mini-xplus.dts  | 65 +
 arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dts  | 64 
 arch/arm/boot/dts/sun4i-a10-pcduino.dts | 58 ++
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 59 ++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts  | 59 ++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 59 ++
 10 files changed, 602 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts 
b/arch/arm/boot/dts/sun4i-a10-a1000.dts
index fa746aea..57d3fb4 100644
--- a/arch/arm/boot/dts/sun4i-a10-a1000.dts
+++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts
@@ -88,6 +88,56 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
+
+   axp209: pmic@34 {
+   compatible = x-powers,axp209;
+   reg = 0x34;
+   interrupts = 0;
+
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   acin-supply = reg_axp_ipsout;
+   vin2-supply = reg_axp_ipsout;
+   vin3-supply = reg_axp_ipsout;
+   ldo24in-supply = reg_axp_ipsout;
+   ldo3in-supply = reg_axp_ipsout;
+   ldo5in-supply = reg_axp_ipsout;
+
+   regulators {
+   x-powers,dcdc-freq = 1500;
+
+   axp_vcore_reg: dcdc2 {
+   regulator-min-microvolt = 
70;
+   regulator-max-microvolt = 
2275000;
+   regulator-always-on;
+   };
+
+   axp_ddr_reg: dcdc3 {
+   regulator-always-on;
+   };
+
+   axp_rtc_reg: ldo1 {
+   regulator-always-on;
+   };
+
+   axp_analog_reg: ldo2 {
+   regulator-always-on;
+   };
+
+   axp_pll_reg: ldo3 {
+   regulator-always-on;
+   };
+
+   axp_hdmi_reg: ldo4 {
+   regulator-always-on;
+   };
+
+   axp_mic_reg: ldo5 {
+   regulator-always-on;
+   };
+   };
+   };
};
};
 
@@ -125,4 +175,12 @@
reg_usb2_vbus: usb2-vbus {
status = okay;
};
+
+   reg_axp_ipsout: axp_ipsout {
+   compatible = regulator-fixed;
+   regulator-name = axp-ipsout;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   regulator-always-on;
+   };
 };
diff --git a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts 
b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
index 4684cbe..0aed114 100644
--- a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
+++ b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
@@ -80,6 +80,56 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
+
+   axp209: pmic@34 {
+   compatible = x-powers,axp209;
+   reg = 0x34;
+   interrupts = 0;
+
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   acin-supply = reg_axp_ipsout;
+   vin2-supply = reg_axp_ipsout;
+   vin3-supply = reg_axp_ipsout;
+   ldo24in-supply = reg_axp_ipsout;
+   ldo3in-supply = reg_axp_ipsout

[linux-sunxi] Re: [PATCH v4 7/9] ARM: sun7i/sun4i: dt: Add AXP209 support to various boards

2014-04-23 Thread Carlo Caione
On Fri, Apr 18, 2014 at 04:15:51PM +0100, Mark Brown wrote:
 On Thu, Apr 17, 2014 at 12:06:34PM +0200, Carlo Caione wrote:
 
  I'm fighting with a small issue when using the
  regulator_bulk_register_supply_alias(). Problem is that when using the
  .parent_supplies entry in the MFD driver, I hit the
  
  WARN_ON(!list_empty(dev-devres_head));
  
  in linux/drivers/base/dd.c#L272, but, apart from the warning,
  everything seems to work correctly.
  A possible explanation I gave myself is that in the mfd_add_device()
  we try to use the devm_* API when the regulator device is not bound to
  the driver yet (I found some information here
  http://lists.infradead.org/pipermail/linux-arm-kernel/2012-June/104442.html).
  Is this the case?
 
 Without knowing more about the case you're hitting it's hard to say - I
 do run a board which exercises the API for a MFD (with the arizona
 drivers) regularly and haven't noticed an issue so there must be
 something different about what you're trying to do.

I'm having a really hard time with this problem, so any hint is welcome
:) The small modification I'm using on top of the patches in this series
is here: http://bpaste.net/show/228330/

Unfortunately as I said I got this when booting:
http://bpaste.net/show/nUhUTzELT32v9HNPathL/

Thanks,

--
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v4 7/9] ARM: sun7i/sun4i: dt: Add AXP209 support to various boards

2014-04-17 Thread Carlo Caione
On Fri, Apr 11, 2014 at 6:18 PM, Mark Brown broo...@kernel.org wrote:
 On Fri, Apr 11, 2014 at 03:04:32PM +0200, Carlo Caione wrote:
 On Fri, Apr 11, 2014 at 2:29 PM, Mark Brown broo...@kernel.org wrote:

  + regulators {
  + compatible = x-powers,axp20x-reg;

  This compatible isn't part of the driver.

 Yes I know. The problem here is that in v4 I had to fill in the field
 .of_compatible of the mfd_cell with x-powers,axp20x-reg. This
 because the regulator_dev_lookup() checks for dev-of_node when
 looking for the supply so I needed the compatible string in the DT to
 have the dev-of_node filled in by mfd_add_device().
 What do you suggest? Modify the regulator driver?

 You're looking for regulator_bulk_register_supply_alias() in the MFD
 driver (via parent_supplies in the MFD cell probably).

Hi Mark,
I'm fighting with a small issue when using the
regulator_bulk_register_supply_alias(). Problem is that when using the
.parent_supplies entry in the MFD driver, I hit the

WARN_ON(!list_empty(dev-devres_head));

in linux/drivers/base/dd.c#L272, but, apart from the warning,
everything seems to work correctly.
A possible explanation I gave myself is that in the mfd_add_device()
we try to use the devm_* API when the regulator device is not bound to
the driver yet (I found some information here
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-June/104442.html).
Is this the case?

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v3 01/10] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-04-11 Thread Carlo Caione
On Fri, Mar 28, 2014 at 10:21 AM, Lee Jones lee.jo...@linaro.org wrote:

[...]

 +static struct resource axp20x_pek_resources[] = {
 + {
 + .name   = PEK_DBR,
 + .start  = AXP20X_IRQ_PEK_RIS_EDGE,
 + .end= AXP20X_IRQ_PEK_RIS_EDGE,
 + .flags  = IORESOURCE_IRQ,
 + }, {
 + .name   = PEK_DBF,
 + .start  = AXP20X_IRQ_PEK_FAL_EDGE,
 + .end= AXP20X_IRQ_PEK_FAL_EDGE,
 + .flags  = IORESOURCE_IRQ,
 + },
 +};

 Have you considered doing this in the Device Tree? It's a lot less
 code/overhead.

Hi Lee,
in v4 (I will send it soon) I left this code in since the resources
are well managed by the MFD core and adding it in the DT results in
pretty much the same code/overhead (atm the input device is not
present in the DT).
If you really think that it is the case to move the code in the DT,
please comment it in the v4.

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v4 9/9] ARM: sunxi: Add AXP20x support multi_v7_defconfig

2014-04-11 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/multi_v7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index ee69829..239c014 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -134,6 +134,7 @@ CONFIG_KEYBOARD_SPEAR=y
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_MOUSE_PS2_ELANTECH=y
 CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_INPUT_MPU3050=y
 CONFIG_SERIO_AMBAKMI=y
 CONFIG_SERIAL_8250=y
@@ -189,6 +190,7 @@ CONFIG_SENSORS_LM90=y
 CONFIG_THERMAL=y
 CONFIG_ARMADA_THERMAL=y
 CONFIG_MFD_AS3722=y
+CONFIG_MFD_AXP20X=y
 CONFIG_MFD_CROS_EC=y
 CONFIG_MFD_CROS_EC_SPI=y
 CONFIG_MFD_MAX8907=y
@@ -199,6 +201,7 @@ CONFIG_MFD_TPS65910=y
 CONFIG_REGULATOR_VIRTUAL_CONSUMER=y
 CONFIG_REGULATOR_AB8500=y
 CONFIG_REGULATOR_AS3722=y
+CONFIG_REGULATOR_AXP20X=y
 CONFIG_REGULATOR_GPIO=y
 CONFIG_REGULATOR_MAX8907=y
 CONFIG_REGULATOR_PALMAS=y
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v4 5/9] input: misc: Add ABI docs for AXP20x PEK

2014-04-11 Thread Carlo Caione
Add ABI entries for the PEK found on PMU X-Powers AXP202 and AXP209.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/ABI/testing/sysfs-driver-input-axp-pek | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek

diff --git a/Documentation/ABI/testing/sysfs-driver-input-axp-pek 
b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
new file mode 100644
index 000..f8cdad2
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
@@ -0,0 +1,11 @@
+What:  /sys/class/input/input(x)/startup
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Startup time. Board is powered on if the button is pressed
+   for more than startup_time
+
+What:  /sys/class/input/input(x)/shutdown
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Shutdown time. Board is powered off if the button is pressed
+   for more than shutdown_time
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v4 3/9] mfd: AXP20x: Add bindings documentation

2014-04-11 Thread Carlo Caione
Bindings documentation for the AXP20x driver. In this file also
sub-nodes are documented.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 96 
 1 file changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt 
b/Documentation/devicetree/bindings/mfd/axp20x.txt
new file mode 100644
index 000..f0d894a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -0,0 +1,96 @@
+AXP202/AXP209 device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible: x-powers,axp202 or x-powers,axp209
+- reg: The I2C slave address for the AXP chip
+- interrupt-parent: The parent interrupt controller
+- interrupts: Interrupt specifiers for interrupt sources
+- interrupt-controller: axp20x has its own internal IRQs
+- #interrupt-cells: Should be set to 1
+- acin-supply: The input supply for LDO1
+- vin2-supply: The input supply for DCDC2
+- vin3-supply: The input supply for DCDC3
+- ldo24in-supply: The input supply for LDO2, LDO4
+- ldo3in-supply: The input supply for LDO3
+- ldo5in-supply: The input supply for LDO5
+
+- regulators: A node that houses a sub-node for each regulator. The regulators 
are
+ bound using their name as listed here: dcdc2, dcdc3, ldo1, ldo2,
+ ldo3, ldo4, ldo5.  The bindings details of individual regulator
+ device can be found in:
+ Documentation/devicetree/bindings/regulator/regulator.txt with
+ the exception of x-powers,dcdc-freq
+- compatible (for regulators): x-powers,axp20x-reg
+- x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
+ (range: 750-1875). Default: 1.5MHz
+
+Optional properties for DCDCs:
+- x-powers,dcdc-workmode: 1 for PWM mode, 0 for AUTO mode
+ Default: AUTO mode
+
+Example:
+
+axp209: pmic@34 {
+   compatible = x-powers,axp209;
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   acin-supply = axp_ipsout_reg;
+   vin2-supply = axp_ipsout_reg;
+   vin3-supply = axp_ipsout_reg;
+   ldo24in-supply = axp_ipsout_reg;
+   ldo3in-supply = axp_ipsout_reg;
+   ldo5in-supply = axp_ipsout_reg;
+
+   regulators {
+   compatible = x-powers,axp20x-reg;
+
+   x-powers,dcdc-freq = 1500;
+
+   axp_vcore_reg: dcdc2 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 2275000;
+   regulator-always-on;
+   };
+
+   axp_ddr_reg: dcdc3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   regulator-always-on;
+   };
+
+   axp_rtc_reg: ldo1 {
+   regulator-always-on;
+   };
+
+   axp_analog_reg: ldo2 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   regulator-always-on;
+   };
+
+   axp_pll_reg: ldo3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   };
+
+   axp_hdmi_reg: ldo4 {
+   regulator-min-microvolt = 125;
+   regulator-max-microvolt = 330;
+   };
+
+   axp_mic_reg: ldo5 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   };
+   };
+};
+
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v4 6/9] regulator: AXP20x: Add support for regulators subsystem

2014-04-11 Thread Carlo Caione
AXP202 and AXP209 come with two synchronous step-down DC-DCs and five
LDOs. This patch introduces basic support for those regulators.

Signed-off-by: Carlo Caione ca...@caione.org
---
 drivers/regulator/Kconfig|   7 +
 drivers/regulator/Makefile   |   1 +
 drivers/regulator/axp20x-regulator.c | 285 +++
 3 files changed, 293 insertions(+)
 create mode 100644 drivers/regulator/axp20x-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 6a79328..9f3bc48 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -139,6 +139,13 @@ config REGULATOR_AS3722
  AS3722 PMIC. This will enable support for all the software
  controllable DCDC/LDO regulators.
 
+config REGULATOR_AXP20X
+   tristate X-POWERS AXP20X PMIC Regulators
+   depends on MFD_AXP20X
+   help
+ This driver provides support for the voltage regulators on the
+ AXP20X PMIC.
+
 config REGULATOR_DA903X
tristate Dialog Semiconductor DA9030/DA9034 regulators
depends on PMIC_DA903X
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 979f9dd..1dd084a 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
 obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
+obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
 obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
 obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
diff --git a/drivers/regulator/axp20x-regulator.c 
b/drivers/regulator/axp20x-regulator.c
new file mode 100644
index 000..78a29e6
--- /dev/null
+++ b/drivers/regulator/axp20x-regulator.c
@@ -0,0 +1,285 @@
+/*
+ * AXP20x regulators driver.
+ *
+ * Copyright (C) 2013 Carlo Caione ca...@caione.org
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/err.h
+#include linux/init.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/mfd/axp20x.h
+#include linux/regulator/driver.h
+#include linux/regulator/of_regulator.h
+
+#define AXP20X_IO_ENABLED  0x03
+#define AXP20X_IO_DISABLED 0x07
+
+#define AXP20X_WORKMODE_DCDC2_MASK BIT(2)
+#define AXP20X_WORKMODE_DCDC3_MASK BIT(1)
+
+#define AXP20X_FREQ_DCDC_MASK  0x0f
+
+#define AXP20X_DESC_IO(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg,  
 \
+  _emask, _enable_val, _disable_val)   
\
+   [AXP20X_##_id] = {  
\
+   .name   = #_id, 
\
+   .supply_name= (_supply),
\
+   .type   = REGULATOR_VOLTAGE,
\
+   .id = AXP20X_##_id, 
\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),
\
+   .owner  = THIS_MODULE,  
\
+   .min_uV = (_min) * 1000,
\
+   .uV_step= (_step) * 1000,   
\
+   .vsel_reg   = (_vreg),  
\
+   .vsel_mask  = (_vmask), 
\
+   .enable_reg = (_ereg),  
\
+   .enable_mask= (_emask), 
\
+   .enable_val = (_enable_val),
\
+   .disable_val= (_disable_val),   
\
+   .ops= axp20x_ops,  
\
+   }
+
+#define AXP20X_DESC(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, 
\
+   _emask) 
\
+   [AXP20X_##_id] = {  
\
+   .name   = #_id, 
\
+   .supply_name= (_supply),
\
+   .type   = REGULATOR_VOLTAGE

[linux-sunxi] [PATCH v4 4/9] input: misc: Add driver for AXP20x Power Enable Key

2014-04-11 Thread Carlo Caione
This patch add support for the Power Enable Key found on MFD AXP202 and
AXP209. Besides the basic support for the button, the driver adds two
entries in sysfs to configure the time delay for power on/off.

Signed-off-by: Carlo Caione ca...@caione.org
---
 drivers/input/misc/Kconfig  |  11 ++
 drivers/input/misc/Makefile |   1 +
 drivers/input/misc/axp20x-pek.c | 261 
 3 files changed, 273 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7904ab0..87244fb 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -393,6 +393,17 @@ config INPUT_RETU_PWRBUTTON
  To compile this driver as a module, choose M here. The module will
  be called retu-pwrbutton.
 
+config INPUT_AXP20X_PEK
+   tristate X-Powers AXP20X power button driver
+   depends on MFD_AXP20X
+   help
+ Say Y here if you want to enable power key reporting via the
+ AXP20X PMIC.
+
+ To compile this driver as a module, choose M here. The module will
+ be called axp20x-pek.
+
+
 config INPUT_TWL4030_PWRBUTTON
tristate TWL4030 Power button Driver
depends on TWL4030_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index cda71fc..624abf5 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
+obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
new file mode 100644
index 000..a9112bd
--- /dev/null
+++ b/drivers/input/misc/axp20x-pek.c
@@ -0,0 +1,261 @@
+/*
+ * axp20x power button driver.
+ *
+ * Copyright (C) 2013 Carlo Caione ca...@caione.org
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/errno.h
+#include linux/irq.h
+#include linux/init.h
+#include linux/input.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/mfd/axp20x.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/slab.h
+
+#define AXP20X_PEK_STARTUP_MASK(0xc0)
+#define AXP20X_PEK_SHUTDOWN_MASK   (0x03)
+
+struct axp20x_pek {
+   struct axp20x_dev *axp20x;
+   struct input_dev *input;
+   int irq_dbr;
+   int irq_dbf;
+};
+
+struct axp20x_time {
+   unsigned int time;
+   unsigned int idx;
+};
+
+static const struct axp20x_time startup_time[] = {
+   { .time = 128,  .idx = 0 },
+   { .time = 1000, .idx = 2 },
+   { .time = 3000, .idx = 1 },
+   { .time = 2000, .idx = 3 },
+};
+
+static const struct axp20x_time shutdown_time[] = {
+   { .time = 4000,  .idx = 0 },
+   { .time = 6000,  .idx = 1 },
+   { .time = 8000,  .idx = 2 },
+   { .time = 1, .idx = 3 },
+};
+
+struct axp20x_pek_ext_attr {
+   const struct axp20x_time *p_time;
+   unsigned int mask;
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = {
+   .p_time = startup_time,
+   .mask   = AXP20X_PEK_STARTUP_MASK,
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = {
+   .p_time = shutdown_time,
+   .mask   = AXP20X_PEK_SHUTDOWN_MASK,
+};
+
+static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute 
*attr)
+{
+   return container_of(attr, struct dev_ext_attribute, attr)-var;
+}
+
+static ssize_t axp20x_show_ext_attr(struct device *dev, struct 
device_attribute *attr,
+   char *buf)
+{
+   struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+   struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
+   unsigned int val;
+   int ret, i;
+
+   ret = regmap_read(axp20x_pek-axp20x-regmap, AXP20X_PEK_KEY, val);
+   if (ret != 0)
+   return ret;
+
+   val = axp20x_ea-mask;
+   val = ffs(axp20x_ea-mask) - 1;
+
+   for (i = 0; i  4; i++)
+   if (val == axp20x_ea-p_time[i].idx)
+   val = axp20x_ea-p_time[i].time;
+
+   return sprintf(buf, %ums\n, val);
+}
+
+static ssize_t axp20x_store_ext_attr(struct device *dev

Re: [linux-sunxi] Re: [PATCH v4 1/9] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-04-11 Thread Carlo Caione
On Fri, Apr 11, 2014 at 1:25 PM, Arnd Bergmann a...@arndb.de wrote:
 On Friday 11 April 2014 11:38:05 Carlo Caione wrote:
 +#define AXP20X_IRQ(_irq, _off, _mask) \
 +   [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
 +
 +static const struct regmap_irq axp20x_regmap_irqs[] = {
 +   AXP20X_IRQ(ACIN_OVER_V, 0, 7),
 +   AXP20X_IRQ(ACIN_PLUGIN, 0, 6),
 +   AXP20X_IRQ(ACIN_REMOVAL,0, 5),
 +   AXP20X_IRQ(VBUS_OVER_V, 0, 4),
 +   AXP20X_IRQ(VBUS_PLUGIN, 0, 3),
 +   AXP20X_IRQ(VBUS_REMOVAL,0, 2),
 +   AXP20X_IRQ(VBUS_V_LOW,  0, 1),
 +   AXP20X_IRQ(BATT_PLUGIN, 1, 7),
 +   AXP20X_IRQ(BATT_REMOVAL,1, 6),
 +   AXP20X_IRQ(BATT_ENT_ACT_MODE,   1, 5),
 +   AXP20X_IRQ(BATT_EXIT_ACT_MODE,  1, 4),
 +   AXP20X_IRQ(CHARG,   1, 3),
 +   AXP20X_IRQ(CHARG_DONE,  1, 2),
 +   AXP20X_IRQ(BATT_TEMP_HIGH,  1, 1),

 Why do you have to enumerate the interrupts here? Can't you just
 put all the numbers into the DT nodes of the devices using them?

 In general, I would say that the mfd driver should not care about
 what is connected to it.

I need this for the regmap irq chip (to be used in regmap_add_irq_chip()).
I'm not sure if you are suggesting to get rid of the irq chip.

br,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v4 6/9] regulator: AXP20x: Add support for regulators subsystem

2014-04-11 Thread Carlo Caione
On Fri, Apr 11, 2014 at 2:23 PM, Mark Brown broo...@kernel.org wrote:
 On Fri, Apr 11, 2014 at 11:38:10AM +0200, Carlo Caione wrote:
 AXP202 and AXP209 come with two synchronous step-down DC-DCs and five
 LDOs. This patch introduces basic support for those regulators.

 Applied, thanks, but I had to resolve some trivial add/add conflicts
 with the Broadcom regulator driver Makefile and Kconfig additions -
 please remember to submit patches against current code.

Sorry, I'll do next time.

Thank you,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v3 04/10] input: misc: Add driver for AXP20x Power Enable Key

2014-03-29 Thread Carlo Caione
On Fri, Mar 28, 2014 at 12:38:03AM -0700, Dmitry Torokhov wrote:
 Hi Carlo,

Hi Dmitry,

 
 On Thu, Mar 27, 2014 at 10:29:18PM +0100, Carlo Caione wrote:

[...]

  +#include linux/errno.h
  +#include linux/irq.h
  +#include linux/init.h
  +#include linux/input.h
  +#include linux/interrupt.h
  +#include linux/kernel.h
  +#include linux/mfd/axp20x.h
  +#include linux/module.h
  +#include linux/platform_device.h
  +#include linux/regmap.h
  +#include linux/slab.h
  +
  +#define AXP20X_PEK_STARTUP_MASK(0xc0)
  +#define AXP20X_PEK_SHUTDOWN_MASK   (0x03)
  +
  +static const char const *startup_time[] = { 128ms, 3s , 1s, 2s };
  +static const char const *shutdown_time[] = { 4s, 6s , 8s, 10s };
 
 Why not have everything expressed in milliseconds and have sysfs
 attribute apply the closest one possible?

Yep, I agree that could be nice. Fix in v3.

 By the way, do you want to plumb these through device tree as well?

Hum, not sure about that. AFAIK device tree is used for hardware
description whereas these are configuration parameters. Moreover you
would have these parameters saved through reboots.

  +
  +struct axp20x_pek {
  +   struct axp20x_dev *axp20x;
  +   struct input_dev *input;
  +   int irq_dbr;
  +   int irq_dbf;
  +};
  +
  +struct axp20x_pek_ext_attr {
  +   const char const **str;
  +   unsigned int mask;
  +};
  +
  +static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = {
  +   .str= startup_time,
  +   .mask   = AXP20X_PEK_STARTUP_MASK,
  +};
  +
  +static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = {
  +   .str= shutdown_time,
  +   .mask   = AXP20X_PEK_SHUTDOWN_MASK,
  +};
  +
  +static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct 
  device_attribute *attr)
  +{
  +   return container_of(attr, struct dev_ext_attribute, attr)-var;
  +}
  +
  +static ssize_t axp20x_show_ext_attr(struct device *dev, struct 
  device_attribute *attr,
  +char *buf)
  +{
  +   struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
  +   struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
  +   unsigned int val;
  +   int ret, i;
  +   int cnt = 0;
  +
  +   ret = regmap_read(axp20x_pek-axp20x-regmap, AXP20X_PEK_KEY, val);
  +   if (ret != 0)
  +   return ret;
  +
  +   val = axp20x_ea-mask;
  +   val = ffs(axp20x_ea-mask) - 1;
  +
  +   for (i = 0; i  4; i++) {
  +   if (val == i)
  +   cnt += sprintf(buf + cnt, [%s] , axp20x_ea-str[i]);
  +   else
  +   cnt += sprintf(buf + cnt, %s , axp20x_ea-str[i]);
 
 Please just return the current value; why do we need pretty-printing?

It was done to have the possibility to look at the accepted values. With
the modification you suggested before this is not necessary anymore.
I'll change it.

  +   }
  +
  +   cnt += sprintf(buf + cnt, \n);
  +
  +   return cnt;
  +}
  +
  +static ssize_t axp20x_store_ext_attr(struct device *dev, struct 
  device_attribute *attr,
  + const char *buf, size_t count)
  +{
  +   struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
  +   struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
  +   char val_str[20];
  +   int ret, i;
  +   size_t len;
  +
  +   val_str[sizeof(val_str) - 1] = '\0';
  +   strncpy(val_str, buf, sizeof(val_str) - 1);
  +   len = strlen(val_str);
  +
  +   if (len  val_str[len - 1] == '\n')
  +   val_str[len - 1] = '\0';
  +
  +   for (i = 0; i  4; i++) {
  +   if (!strcmp(val_str, axp20x_ea-str[i])) {
  +
  +   i = ffs(axp20x_ea-mask) - 1;
  +   ret = regmap_update_bits(axp20x_pek-axp20x-regmap,
  +AXP20X_PEK_KEY,
  +axp20x_ea-mask, i);
  +   if (ret != 0)
  +   return -EINVAL;
  +   return count;
  +   }
  +   }
  +
  +   return -EINVAL;
  +}
  +
  +static struct dev_ext_attribute axp20x_dev_attr_startup = {
  +   .attr   = __ATTR(startup, 0644, axp20x_show_ext_attr, 
  axp20x_store_ext_attr),
  +   .var= axp20x_pek_startup_ext_attr
  +};
  +
  +static struct dev_ext_attribute axp20x_dev_attr_shutdown = {
  +   __ATTR(shutdown, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr),
  +   axp20x_pek_shutdown_ext_attr
  +};
  +
  +static struct attribute *dev_attrs[] = {
  +   axp20x_dev_attr_startup.attr.attr,
  +   axp20x_dev_attr_shutdown.attr.attr,
  +   NULL,
  +};
  +
  +static struct attribute_group dev_attr_group = {
  +   .attrs  = dev_attrs,
  +};
  +
  +static const struct attribute_group *dev_attr_groups[] = {
  +   dev_attr_group,
  +   NULL,
  +};
  +
  +static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
  +{
  +   struct input_dev *idev = pwr;
  +   struct axp20x_pek *axp20x_pek = input_get_drvdata(idev);
  +
  +   if (irq == axp20x_pek-irq_dbr)
  +   input_report_key(idev, KEY_POWER, true);
  +   else if (irq == axp20x_pek

Re: [linux-sunxi] Re: [PATCH v3 06/10] regulator: AXP20x: Add support for regulators subsystem

2014-03-29 Thread Carlo Caione
On Fri, Mar 28, 2014 at 01:39:34PM +, Mark Brown wrote:
 On Thu, Mar 27, 2014 at 10:29:20PM +0100, Carlo Caione wrote:
 
  +static int axp20x_set_suspend_voltage(struct regulator_dev *rdev, int uV)
  +{
  +   int sel = regulator_map_voltage_iterate(rdev, uV, uV);
  +
  +   if (sel  0)
  +   return sel;
  +
  +   return regulator_set_voltage_sel_regmap(rdev, sel);
  +}
 
 This is fairly obviously broken - it's overwriting the normal runtime
 value, this will disrupt the running system if we want the value we use
 on suspend is different to the value we want at runtime.

Ok, silly question: isn't it exactly what we want? Set the voltage for
the regulator when the system is suspended?

 Think about it - if this was a sane thing to do the core would just do
 it without needing driver specific code, we already know how to set the
 voltage for the device.

I thought it was because some regulators can have specific regs for
managing the suspend mode.

BTW, but then what is the difference between my code and (i.e.) the same
routine in da9055-regulator.c?

http://lxr.linux.no/linux+v3.13.5/drivers/regulator/da9055-regulator.c#L276

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH 0/2] ARM: sun7i/sun6i: Fix broken kernel on sun6i/A31

2014-03-27 Thread Carlo Caione
These fixes are proposed by Hans de Goede to fix the broken kernel on
sun6i/A31. The major problem is that the IRQ number for NMI on sun6i is wrong.
Besides that, Hans proposed a fix to avoid having sporious interrupts when the
NMI line is asserted but no driver has claimed the downstream interrupt of the
NMI.

Hans de Goede (2):
  ARM: sun7i/sun6i: dts: Fix IRQ number for sun6i NMI controller
  ARM: sun7i/sun6i: irqchip: Disable NMI before registering the handler

 arch/arm/boot/dts/sun6i-a31.dtsi | 2 +-
 drivers/irqchip/irq-sunxi-nmi.c  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
1.8.4.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH 1/2] ARM: sun7i/sun6i: dts: Fix IRQ number for sun6i NMI controller

2014-03-27 Thread Carlo Caione
From: Hans de Goede hdego...@redhat.com

The IRQ line used in sun6i-a31.dtsi for the NMI controller is wrong.
This causes a IRQ storm since the NMI controller is repeatedly fired.
This patch fixes this problem assigning the correct IRQ number to the
NMI controller.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/boot/dts/sun6i-a31.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index 3b95cb5..38d43fe 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -195,7 +195,7 @@
interrupt-controller;
#interrupt-cells = 2;
reg = 0x01f00c0c 0x38;
-   interrupts = 0 0 4;
+   interrupts = 0 32 4;
};
 
pio: pinctrl@01c20800 {
-- 
1.8.4.1

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v3 02/10] dt-bindings: add vendor-prefix for X-Powers

2014-03-27 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 40ce2df..d06ba8c 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -95,3 +95,4 @@ winbond Winbond Electronics corp.
 wlfWolfson Microelectronics
 wm Wondermedia Technologies, Inc.
 xlnx   Xilinx
+x-powers   X-Powers
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v3 03/10] mfd: AXP20x: Add bindings documentation

2014-03-27 Thread Carlo Caione
Bindings documentation for the AXP20x driver. In this file also
sub-nodes are documented.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 83 
 1 file changed, 83 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt 
b/Documentation/devicetree/bindings/mfd/axp20x.txt
new file mode 100644
index 000..ebc6772
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -0,0 +1,83 @@
+* axp20x device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible   : Should be x-powers,axp202 or 
x-powers,axp209
+- interrupt-controller : axp20x has its own internal IRQs
+- #interrupt-cells : Should be set to 1
+- interrupt-parent : The parent interrupt controller
+- interrupts   : Interrupt specifiers for interrupt sources
+- reg  : The I2C slave address for the AXP chip
+
+Sub-nodes:
+* regulators : Contain the regulator nodes. The regulators are bound using
+  their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3,
+  ldo4, ldo5.
+  The bindings details of individual regulator device can be found 
in:
+  Documentation/devicetree/bindings/regulator/regulator.txt with 
the
+  exception of:
+
+   - x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
+ (range: 750-1875). Default: 1.5MHz
+
+   For each DCDC:
+   - x-powers,dcdc-workmode: Optional. 1 for PWM mode, 0 for AUTO 
mode
+ Default: AUTO mode
+
+Example:
+
+axp: axp20x@34 {
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   compatible = x-powers,axp209;
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   regulators {
+   dcdc-freq = 1500;
+
+   axp_dcdc2: dcdc2 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 2275000;
+   regulator-always-on;
+   };
+
+   axp_dcdc3: dcdc3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   regulator-always-on;
+   };
+
+   axp_ldo1: ldo1 {
+   regulator-min-microvolt = 130;
+   regulator-max-microvolt = 130;
+   };
+
+   axp_ldo2: ldo2 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   regulator-always-on;
+   };
+
+   axp_ldo3: ldo3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   };
+
+   axp_ldo4: ldo4 {
+   regulator-min-microvolt = 125;
+   regulator-max-microvolt = 330;
+   };
+
+   axp_ldo5: ldo5 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   };
+   };
+};
+
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v3 06/10] regulator: AXP20x: Add support for regulators subsystem

2014-03-27 Thread Carlo Caione
AXP202 and AXP209 come with two synchronous step-down DC-DCs and five
LDOs. This patch introduces basic support for those regulators.

Signed-off-by: Carlo Caione ca...@caione.org
---
 drivers/regulator/Kconfig|   7 +
 drivers/regulator/Makefile   |   1 +
 drivers/regulator/axp20x-regulator.c | 280 +++
 3 files changed, 288 insertions(+)
 create mode 100644 drivers/regulator/axp20x-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 6a79328..9f3bc48 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -139,6 +139,13 @@ config REGULATOR_AS3722
  AS3722 PMIC. This will enable support for all the software
  controllable DCDC/LDO regulators.
 
+config REGULATOR_AXP20X
+   tristate X-POWERS AXP20X PMIC Regulators
+   depends on MFD_AXP20X
+   help
+ This driver provides support for the voltage regulators on the
+ AXP20X PMIC.
+
 config REGULATOR_DA903X
tristate Dialog Semiconductor DA9030/DA9034 regulators
depends on PMIC_DA903X
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 979f9dd..1dd084a 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
 obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
+obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
 obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
 obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
diff --git a/drivers/regulator/axp20x-regulator.c 
b/drivers/regulator/axp20x-regulator.c
new file mode 100644
index 000..3f1db88
--- /dev/null
+++ b/drivers/regulator/axp20x-regulator.c
@@ -0,0 +1,280 @@
+/*
+ * AXP20x regulators driver.
+ *
+ * Copyright (C) 2013 Carlo Caione ca...@caione.org
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/err.h
+#include linux/init.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/mfd/axp20x.h
+#include linux/regulator/driver.h
+#include linux/regulator/of_regulator.h
+
+#define AXP20X_IO_ENABLED  (0x03)
+#define AXP20X_IO_DISABLED (0x07)
+
+#define AXP20X_WORKMODE_DCDC2_MASK BIT(2)
+#define AXP20X_WORKMODE_DCDC3_MASK BIT(1)
+
+#define AXP20X_FREQ_DCDC_MASK  (0x0f)
+
+#define AXP20X_DESC_IO(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask,   
\
+  _enable_val, _disable_val)   
\
+   [AXP20X_##_id] = {  
\
+   .name   = #_id, 
\
+   .type   = REGULATOR_VOLTAGE,
\
+   .id = AXP20X_##_id, 
\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),
\
+   .owner  = THIS_MODULE,  
\
+   .min_uV = (_min) * 1000,
\
+   .uV_step= (_step) * 1000,   
\
+   .vsel_reg   = (_vreg),  
\
+   .vsel_mask  = (_vmask), 
\
+   .enable_reg = (_ereg),  
\
+   .enable_mask= (_emask), 
\
+   .enable_val = (_enable_val),
\
+   .disable_val= (_disable_val),   
\
+   .ops= axp20x_ops,  
\
+   }
+
+#define AXP20X_DESC(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask)  
\
+   AXP20X_DESC_IO(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask,
\
+  0, 0)
+
+#define AXP20X_DESC_FIXED(_id, _volt)  
\
+   [AXP20X_##_id] = {  
\
+   .name   = #_id, 
\
+   .type   = REGULATOR_VOLTAGE,
\
+   .id = AXP20X_##_id

[linux-sunxi] [PATCH v3 05/10] input: misc: Add ABI docs for AXP20x PEK

2014-03-27 Thread Carlo Caione
Add ABI entries for the PEK found on PMU X-Powers AXP202 and AXP209.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/ABI/testing/sysfs-driver-input-axp-pek | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek

diff --git a/Documentation/ABI/testing/sysfs-driver-input-axp-pek 
b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
new file mode 100644
index 000..f8cdad2
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
@@ -0,0 +1,11 @@
+What:  /sys/class/input/input(x)/startup
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Startup time. Board is powered on if the button is pressed
+   for more than startup_time
+
+What:  /sys/class/input/input(x)/shutdown
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Shutdown time. Board is powered off if the button is pressed
+   for more than shutdown_time
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v3 00/10] mfd: AXP20x: Add support for AXP202 and AXP209

2014-03-27 Thread Carlo Caione
AXP209 and AXP202 are the PMUs (Power Management Unit) used by A10, A13
and A20 SoCs and developed by X-Powers, a sister company of Allwinner.
AXP20x comprises an adaptive USB-Compatible PWM charger, 2 BUCK DC-DC
converters, 5 LDOs, multiple 12-bit ADCs of voltage, current and temperature
as well as 4 configurable GPIOs. 

This set of patches introduces the core driver and support for two different
subsystems:
- Regulators
- PEK (Power Enable Key)

This patchset depends on patchsets:
irq: sun4i IRQ 0 / ENMI fixes (Hans de Goede)
ARM: sun7i/sun6i: irqchip: Irqchip driver for NMI controller (Carlo 
Caione)
regulator: helpers: Modify helpers enabling multi-bit control (Carlo 
Caione)

Changes since v1:

- Added a new standalone patch for defconfig

- MFD core:
  * Removed axp,system-power-controller property

- Bindings documentation:
  * Corrected description for dcdc-workmode property
  * Removed unused axp20x-pek compatible

- Input misc PEK driver:
  * Fixed seconds in lower case

- Regulators subsystem:
  * Fixed axp20x_set_suspend_voltage()
  * Switched to using multi-bit control for regulators
  * When regulators node is not found driver doesn't quit
  * Driver is now using devm_regulator_register()
  * Added module_platform_driver() instead of subsys_initcall()

- DT:
  * Added new DTSI for AXP209
  * Added support for cubietruck and olinuxino-micro

Changes since v2:

- Added a new patch for multi_v7_defconfig to enable MFD core
  and subsystems

- DT:
  * Dropped axp,system-power-controller property from DTS
  * Moved compatible and interrupt-related properties from the
DTSI file to the DTS board files

- Regulators subsystem:
  * Deleted useless struct axp20x_regulators
  * Added a warning when out of specs values are used for the
dcdc frequency

- MFD core:
  * Fixed coding style
  * Removed IDs from device table for i2c

- Bindings documentation:
  * Several corrections and fixes

Carlo Caione (10):
  mfd: AXP20x: Add mfd driver for AXP20x PMIC
  dt-bindings: add vendor-prefix for X-Powers
  mfd: AXP20x: Add bindings documentation
  input: misc: Add driver for AXP20x Power Enable Key
  input: misc: Add ABI docs for AXP20x PEK
  regulator: AXP20x: Add support for regulators subsystem
  ARM: sunxi: dt: Add x-powers-axp209.dtsi file
  ARM: sun7i/sun4i: dt: Add AXP209 support to various boards
  ARM: sunxi: Add AXP20x support in defconfig
  ARM: sunxi: Add AXP20x support multi_v7_defconfig

 .../ABI/testing/sysfs-driver-input-axp-pek |  11 +
 Documentation/devicetree/bindings/mfd/axp20x.txt   |  83 ++
 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 arch/arm/boot/dts/sun4i-a10-a1000.dts  |  13 +
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts |  13 +
 arch/arm/boot/dts/sun4i-a10-hackberry.dts  |  19 ++
 arch/arm/boot/dts/sun4i-a10-inet97fv2.dts  |  13 +
 arch/arm/boot/dts/sun4i-a10-mini-xplus.dts |  19 ++
 arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dts |  19 ++
 arch/arm/boot/dts/sun4i-a10-pcduino.dts|  13 +
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts|  14 ++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts |  15 ++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts|  14 ++
 arch/arm/boot/dts/x-powers-axp209.dtsi |  54 
 arch/arm/configs/multi_v7_defconfig|   3 +
 arch/arm/configs/sunxi_defconfig   |   4 +
 drivers/input/misc/Kconfig |  11 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/axp20x-pek.c| 260 +++
 drivers/mfd/Kconfig|  12 +
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/axp20x.c   | 240 ++
 drivers/regulator/Kconfig  |   7 +
 drivers/regulator/Makefile |   1 +
 drivers/regulator/axp20x-regulator.c   | 280 +
 include/linux/mfd/axp20x.h | 180 +
 26 files changed, 1301 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
 create mode 100644 arch/arm/boot/dts/x-powers-axp209.dtsi
 create mode 100644 drivers/input/misc/axp20x-pek.c
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 drivers/regulator/axp20x-regulator.c
 create mode 100644 include/linux/mfd/axp20x.h

-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from

[linux-sunxi] [PATCH v3 01/10] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-03-27 Thread Carlo Caione
This patch introduces the preliminary support for PMICs X-Powers AXP202
and AXP209. The AXP209 and AXP202 are the PMUs (Power Management Unit)
used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company
of Allwinner.

The core enables support for two subsystems:
- PEK (Power Enable Key)
- Regulators

Signed-off-by: Carlo Caione ca...@caione.org
---
 drivers/mfd/Kconfig|  12 +++
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/axp20x.c   | 240 +
 include/linux/mfd/axp20x.h | 180 ++
 4 files changed, 433 insertions(+)
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 include/linux/mfd/axp20x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 49bb445..24ba61a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -59,6 +59,18 @@ config MFD_AAT2870_CORE
  additional drivers must be enabled in order to use the
  functionality of the device.
 
+config MFD_AXP20X
+   bool X-Powers AXP20X
+   select MFD_CORE
+   select REGMAP_I2C
+   select REGMAP_IRQ
+   depends on I2C=y
+   help
+ If you say Y here you get support for the AXP20X.
+ This driver provides common support for accessing the device,
+ additional drivers must be enabled in order to use the
+ functionality of the device.
+
 config MFD_CROS_EC
tristate ChromeOS Embedded Controller
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 5aea5ef..fb773b5 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -101,6 +101,7 @@ obj-$(CONFIG_PMIC_DA9052)   += da9052-irq.o
 obj-$(CONFIG_PMIC_DA9052)  += da9052-core.o
 obj-$(CONFIG_MFD_DA9052_SPI)   += da9052-spi.o
 obj-$(CONFIG_MFD_DA9052_I2C)   += da9052-i2c.o
+obj-$(CONFIG_MFD_AXP20X)   += axp20x.o
 
 obj-$(CONFIG_MFD_LP3943)   += lp3943.o
 obj-$(CONFIG_MFD_LP8788)   += lp8788.o lp8788-irq.o
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
new file mode 100644
index 000..f77a663
--- /dev/null
+++ b/drivers/mfd/axp20x.c
@@ -0,0 +1,240 @@
+/*
+ * axp20x.c - MFD core driver for the X-Powers AXP202 and AXP209
+ *
+ * Author: Carlo Caione ca...@caione.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/pm_runtime.h
+#include linux/regmap.h
+#include linux/slab.h
+#include linux/regulator/consumer.h
+#include linux/mfd/axp20x.h
+#include linux/mfd/core.h
+#include linux/of_device.h
+#include linux/of_irq.h
+
+#define AXP20X_OFF 0x80
+
+static const struct regmap_range axp20x_writeable_ranges[] = {
+   regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
+   regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
+};
+
+static const struct regmap_range axp20x_volatile_ranges[] = {
+   regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
+};
+
+static const struct regmap_access_table axp20x_writeable_table = {
+   .yes_ranges = axp20x_writeable_ranges,
+   .n_yes_ranges   = ARRAY_SIZE(axp20x_writeable_ranges),
+};
+
+static const struct regmap_access_table axp20x_volatile_table = {
+   .yes_ranges = axp20x_volatile_ranges,
+   .n_yes_ranges   = ARRAY_SIZE(axp20x_volatile_ranges),
+};
+
+static struct resource axp20x_pek_resources[] = {
+   {
+   .name   = PEK_DBR,
+   .start  = AXP20X_IRQ_PEK_RIS_EDGE,
+   .end= AXP20X_IRQ_PEK_RIS_EDGE,
+   .flags  = IORESOURCE_IRQ,
+   }, {
+   .name   = PEK_DBF,
+   .start  = AXP20X_IRQ_PEK_FAL_EDGE,
+   .end= AXP20X_IRQ_PEK_FAL_EDGE,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static const struct regmap_config axp20x_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .wr_table   = axp20x_writeable_table,
+   .volatile_table = axp20x_volatile_table,
+   .max_register   = AXP20X_FG_RES,
+   .cache_type = REGCACHE_RBTREE,
+};
+
+#define AXP20X_IRQ(_irq, _off, _mask) \
+   [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
+
+static const struct regmap_irq axp20x_regmap_irqs[] = {
+   AXP20X_IRQ(ACIN_OVER_V, 0, 7),
+   AXP20X_IRQ(ACIN_PLUGIN, 0, 6),
+   AXP20X_IRQ(ACIN_REMOVAL,0, 5),
+   AXP20X_IRQ(VBUS_OVER_V, 0, 4),
+   AXP20X_IRQ(VBUS_PLUGIN, 0, 3),
+   AXP20X_IRQ(VBUS_REMOVAL,0, 2),
+   AXP20X_IRQ(VBUS_V_LOW,  0, 1),
+   AXP20X_IRQ(BATT_PLUGIN, 1, 7),
+   AXP20X_IRQ(BATT_REMOVAL,1, 6),
+   AXP20X_IRQ(BATT_ENT_ACT_MODE,   1, 5),
+   AXP20X_IRQ(BATT_EXIT_ACT_MODE,  1, 4

[linux-sunxi] [PATCH v3 04/10] input: misc: Add driver for AXP20x Power Enable Key

2014-03-27 Thread Carlo Caione
This patch add support for the Power Enable Key found on MFD AXP202 and
AXP209. Besides the basic support for the button, the driver adds two
entries in sysfs to configure the time delay for power on/off.

Signed-off-by: Carlo Caione ca...@caione.org
---
 drivers/input/misc/Kconfig  |  11 ++
 drivers/input/misc/Makefile |   1 +
 drivers/input/misc/axp20x-pek.c | 260 
 3 files changed, 272 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7904ab0..87244fb 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -393,6 +393,17 @@ config INPUT_RETU_PWRBUTTON
  To compile this driver as a module, choose M here. The module will
  be called retu-pwrbutton.
 
+config INPUT_AXP20X_PEK
+   tristate X-Powers AXP20X power button driver
+   depends on MFD_AXP20X
+   help
+ Say Y here if you want to enable power key reporting via the
+ AXP20X PMIC.
+
+ To compile this driver as a module, choose M here. The module will
+ be called axp20x-pek.
+
+
 config INPUT_TWL4030_PWRBUTTON
tristate TWL4030 Power button Driver
depends on TWL4030_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index cda71fc..624abf5 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
+obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
new file mode 100644
index 000..6698a69
--- /dev/null
+++ b/drivers/input/misc/axp20x-pek.c
@@ -0,0 +1,260 @@
+/*
+ * axp20x power button driver.
+ *
+ * Copyright (C) 2013 Carlo Caione ca...@caione.org
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/errno.h
+#include linux/irq.h
+#include linux/init.h
+#include linux/input.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/mfd/axp20x.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/slab.h
+
+#define AXP20X_PEK_STARTUP_MASK(0xc0)
+#define AXP20X_PEK_SHUTDOWN_MASK   (0x03)
+
+static const char const *startup_time[] = { 128ms, 3s , 1s, 2s };
+static const char const *shutdown_time[] = { 4s, 6s , 8s, 10s };
+
+struct axp20x_pek {
+   struct axp20x_dev *axp20x;
+   struct input_dev *input;
+   int irq_dbr;
+   int irq_dbf;
+};
+
+struct axp20x_pek_ext_attr {
+   const char const **str;
+   unsigned int mask;
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = {
+   .str= startup_time,
+   .mask   = AXP20X_PEK_STARTUP_MASK,
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = {
+   .str= shutdown_time,
+   .mask   = AXP20X_PEK_SHUTDOWN_MASK,
+};
+
+static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute 
*attr)
+{
+   return container_of(attr, struct dev_ext_attribute, attr)-var;
+}
+
+static ssize_t axp20x_show_ext_attr(struct device *dev, struct 
device_attribute *attr,
+char *buf)
+{
+   struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+   struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
+   unsigned int val;
+   int ret, i;
+   int cnt = 0;
+
+   ret = regmap_read(axp20x_pek-axp20x-regmap, AXP20X_PEK_KEY, val);
+   if (ret != 0)
+   return ret;
+
+   val = axp20x_ea-mask;
+   val = ffs(axp20x_ea-mask) - 1;
+
+   for (i = 0; i  4; i++) {
+   if (val == i)
+   cnt += sprintf(buf + cnt, [%s] , axp20x_ea-str[i]);
+   else
+   cnt += sprintf(buf + cnt, %s , axp20x_ea-str[i]);
+   }
+
+   cnt += sprintf(buf + cnt, \n);
+
+   return cnt;
+}
+
+static ssize_t axp20x_store_ext_attr(struct device *dev, struct 
device_attribute *attr,
+ const char *buf, size_t count)
+{
+   struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+   struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr

[linux-sunxi] [PATCH v3 07/10] ARM: sunxi: dt: Add x-powers-axp209.dtsi file

2014-03-27 Thread Carlo Caione
This dtsi describes the axp209 PMIC, and is to be included from inside
the i2c controller node to which the axp209 is connected.

Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/boot/dts/x-powers-axp209.dtsi | 54 ++
 1 file changed, 54 insertions(+)
 create mode 100644 arch/arm/boot/dts/x-powers-axp209.dtsi

diff --git a/arch/arm/boot/dts/x-powers-axp209.dtsi 
b/arch/arm/boot/dts/x-powers-axp209.dtsi
new file mode 100644
index 000..b05e54d
--- /dev/null
+++ b/arch/arm/boot/dts/x-powers-axp209.dtsi
@@ -0,0 +1,54 @@
+/*
+ * x-powers,axp209 common code to be include from inside the axp209 node
+ *
+ * Copyright 2014 - Carlo Caione ca...@caione.org
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+regulators {
+   dcdc-freq = 1500;
+
+   axp_dcdc2: dcdc2 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 2275000;
+   regulator-always-on;
+   };
+
+   axp_dcdc3: dcdc3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   regulator-always-on;
+   };
+
+   axp_ldo1: ldo1 {
+   regulator-min-microvolt = 130;
+   regulator-max-microvolt = 130;
+   };
+
+   axp_ldo2: ldo2 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   regulator-always-on;
+   };
+
+   axp_ldo3: ldo3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   };
+
+   axp_ldo4: ldo4 {
+   regulator-min-microvolt = 125;
+   regulator-max-microvolt = 330;
+   };
+
+   axp_ldo5: ldo5 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   };
+};
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v3 10/10] ARM: sunxi: Add AXP20x support multi_v7_defconfig

2014-03-27 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/multi_v7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index ee69829..239c014 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -134,6 +134,7 @@ CONFIG_KEYBOARD_SPEAR=y
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_MOUSE_PS2_ELANTECH=y
 CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_INPUT_MPU3050=y
 CONFIG_SERIO_AMBAKMI=y
 CONFIG_SERIAL_8250=y
@@ -189,6 +190,7 @@ CONFIG_SENSORS_LM90=y
 CONFIG_THERMAL=y
 CONFIG_ARMADA_THERMAL=y
 CONFIG_MFD_AS3722=y
+CONFIG_MFD_AXP20X=y
 CONFIG_MFD_CROS_EC=y
 CONFIG_MFD_CROS_EC_SPI=y
 CONFIG_MFD_MAX8907=y
@@ -199,6 +201,7 @@ CONFIG_MFD_TPS65910=y
 CONFIG_REGULATOR_VIRTUAL_CONSUMER=y
 CONFIG_REGULATOR_AB8500=y
 CONFIG_REGULATOR_AS3722=y
+CONFIG_REGULATOR_AXP20X=y
 CONFIG_REGULATOR_GPIO=y
 CONFIG_REGULATOR_MAX8907=y
 CONFIG_REGULATOR_PALMAS=y
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v3 08/10] ARM: sun7i/sun4i: dt: Add AXP209 support to various boards

2014-03-27 Thread Carlo Caione
Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/boot/dts/sun4i-a10-a1000.dts   | 13 +
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts  | 13 +
 arch/arm/boot/dts/sun4i-a10-hackberry.dts   | 19 +++
 arch/arm/boot/dts/sun4i-a10-inet97fv2.dts   | 13 +
 arch/arm/boot/dts/sun4i-a10-mini-xplus.dts  | 19 +++
 arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dts  | 19 +++
 arch/arm/boot/dts/sun4i-a10-pcduino.dts | 13 +
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 14 ++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts  | 15 +++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 14 ++
 10 files changed, 152 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts 
b/arch/arm/boot/dts/sun4i-a10-a1000.dts
index fa746aea..cf18c4d 100644
--- a/arch/arm/boot/dts/sun4i-a10-a1000.dts
+++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts
@@ -88,6 +88,19 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   axp: axp20x@34 {
+   reg = 0x34;
+   interrupts = 0;
+
+   compatible = x-powers,axp209;
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   /include/ x-powers-axp209.dtsi
+   };
};
};
 
diff --git a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts 
b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
index 4684cbe..52d21bb 100644
--- a/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
+++ b/arch/arm/boot/dts/sun4i-a10-cubieboard.dts
@@ -80,6 +80,19 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   axp: axp20x@34 {
+   reg = 0x34;
+   interrupts = 0;
+
+   compatible = x-powers,axp209;
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   /include/ x-powers-axp209.dtsi
+   };
};
 
i2c1: i2c@01c2b000 {
diff --git a/arch/arm/boot/dts/sun4i-a10-hackberry.dts 
b/arch/arm/boot/dts/sun4i-a10-hackberry.dts
index d7c17e4..3960d67 100644
--- a/arch/arm/boot/dts/sun4i-a10-hackberry.dts
+++ b/arch/arm/boot/dts/sun4i-a10-hackberry.dts
@@ -82,6 +82,25 @@
pinctrl-0 = uart0_pins_a;
status = okay;
};
+
+   i2c0: i2c@01c2ac00 {
+   pinctrl-names = default;
+   pinctrl-0 = i2c0_pins_a;
+   status = okay;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   axp: axp20x@34 {
+   reg = 0x34;
+   interrupts = 0;
+
+   compatible = x-powers,axp209;
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   /include/ x-powers-axp209.dtsi
+   };
+   };
};
 
reg_emac_3v3: emac-3v3 {
diff --git a/arch/arm/boot/dts/sun4i-a10-inet97fv2.dts 
b/arch/arm/boot/dts/sun4i-a10-inet97fv2.dts
index fe9272e..c797f5c 100644
--- a/arch/arm/boot/dts/sun4i-a10-inet97fv2.dts
+++ b/arch/arm/boot/dts/sun4i-a10-inet97fv2.dts
@@ -34,6 +34,19 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   axp: axp20x@34 {
+   reg = 0x34;
+   interrupts = 0;
+
+   compatible = x-powers,axp209;
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   /include/ x-powers-axp209.dtsi
+   };
};
 
usbphy: phy@01c13400 {
diff --git a/arch/arm/boot/dts/sun4i-a10-mini-xplus.dts 
b/arch/arm/boot/dts/sun4i-a10-mini-xplus.dts
index dd84a9e..c61902d 100644
--- a/arch/arm/boot/dts/sun4i-a10-mini-xplus.dts
+++ b/arch/arm/boot/dts/sun4i-a10-mini-xplus.dts
@@ -47,6 +47,25 @@
pinctrl-0 = uart0_pins_a;
status = okay

[linux-sunxi] [PATCH v3 09/10] ARM: sunxi: Add AXP20x support in defconfig

2014-03-27 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/sunxi_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig
index b5df4a5..6e305da 100644
--- a/arch/arm/configs/sunxi_defconfig
+++ b/arch/arm/configs/sunxi_defconfig
@@ -40,6 +40,8 @@ CONFIG_SUN4I_EMAC=y
 # CONFIG_NET_VENDOR_STMICRO is not set
 # CONFIG_NET_VENDOR_WIZNET is not set
 # CONFIG_WLAN is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=8
@@ -55,6 +57,7 @@ CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
 CONFIG_SUNXI_WATCHDOG=y
+CONFIG_MFD_AXP20X=y
 # CONFIG_USB_SUPPORT is not set
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
@@ -69,3 +72,4 @@ CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
 CONFIG_NLS=y
 CONFIG_PRINTK_TIME=y
+CONFIG_REGULATOR_AXP20X=y
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v7 2/3] ARM: sun7i/sun6i: dts: Add NMI irqchip support

2014-03-26 Thread Carlo Caione
On Wed, Mar 26, 2014 at 03:38:05PM +0100, Hans de Goede wrote:
 Hi,

Hi Hans,

 On 03/26/2014 11:04 AM, Hans de Goede wrote:
  Hi,
 
  On 03/26/2014 10:39 AM, Maxime Ripard wrote:
  On Wed, Mar 26, 2014 at 09:39:31AM +0100, Hans de Goede wrote:
  Hi,
 
  On 03/19/2014 08:21 PM, Carlo Caione wrote:
  This patch adds DTS entries for NMI controller as child of GIC.
 
  Signed-off-by: Carlo Caione ca...@caione.org
 
  Note this breaks the kernel on sun6i / A31 since we don't have a
  pmic driver there yet, and thus the nmi gets constantly fired without
  anything clearing it.
 
  So the sun6i section needs a status = disabled; until we actually have 
  pmic
  support.
 
  I guess it also applies to the A20, since the PMIC patches will
  probably get merged later on?
 
  Could be I've never tried it on the A20 without also having the pmic driver
  build into the kernel. Thinking more about this, I think this actually is
  a bug in the nmi irqchip driver, it should not unmask the gic irq until
  it gets an unmask for its child irq itself.
 
  Otherwise we can still get the same problem if ie the pmic driver is
  a module, etc.
 
  Hmm, looking at the code I see that it already masks (sets enable to 0)
  the irq in sunxi_sc_nmi_irq_init. Note that this really should be
  done before the irq_set_chained_handler call though, as from then on
  the gic irq is unmasked, so we may get spurious irqs until the
  sunxi_sc_nmi_write calls are done.
 
  I don't think this will solve the A31 problem though, I wonder if
  the enable reg-offset we've for the A31 is correct, maybe it should
  be 8 like with the A20 ?
 
  I'll give this a try when I can find some time for this.

 Ok, so I've spend some time debugging this, and the problem is not the
 disabling of the NMI in the NMI controller itself. The problem is that
 the irq line used in the sun6i-a31.dtsi is wrong, irq 0 is for uart0
 the nmi uses irq 32. So this fixes this hang due to unhandled irqs

Unfortunately I don't have a A31 board so I couldn't test it :( sorry for
this mess.
I have tried with my Cubieboard2 and it seems that I don't have any IRQs
storm when the PMIC is not compiled in.

 I've been seeing:

 --- a/arch/arm/boot/dts/sun6i-a31.dtsi
 +++ b/arch/arm/boot/dts/sun6i-a31.dtsi
 @@ -603,8 +603,7 @@
 interrupt-controller;
 #interrupt-cells = 2;
 reg = 0x01f00c0c 0x38;
 -   interrupt-parent = gic;
 -   interrupts = 0 0 4;
 +   interrupts = 0 32 4;
 };

 cpucfg@01f01c00 {

Agree. I'll fix it.

 Note I also remove the interrupt-parent as the gic is the
 default interrupt-parent, and we don't explicitly set that
 anywhere else either.

Uhm, actually I removed it in v6. Probably you are looking at the wrong
version.

 Besides that after having looked into this more, I strongly
 believe that we should disable the NMI before registering the
 irq handler, as registering the irq handler unmasks the irq
 on the gic, so if u-boot has left the NMI enabled, and the NMI pin
 is active we will immediately get an interrupt, before any
 driver has claimed the downstream interrupt of the NMI.

 IOW I strongly believe we should do this:

 --- a/drivers/irqchip/irq-sunxi-nmi.c
 +++ b/drivers/irqchip/irq-sunxi-nmi.c
 @@ -179,12 +179,12 @@ static int __init sunxi_sc_nmi_irq_init(struct 
 device_node *node,
 gc-chip_types[1].regs.type = reg_offs-ctrl;
 gc-chip_types[1].handler   = handle_edge_irq;

 -   irq_set_handler_data(irq, domain);
 -   irq_set_chained_handler(irq, sunxi_sc_nmi_handle_irq);
 -
 sunxi_sc_nmi_write(gc, reg_offs-enable, 0);
 sunxi_sc_nmi_write(gc, reg_offs-pend, 0x1);

 +   irq_set_handler_data(irq, domain);
 +   irq_set_chained_handler(irq, sunxi_sc_nmi_handle_irq);
 +
 return 0;

  fail_irqd_remove:

ACK


 So it looks like we need a v8, sorry for not spotting this sooner.

My bad for not having tested it enough.

Thank you,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v8 1/3] ARM: sun7i/sun6i: irqchip: Add irqchip driver for NMI controller

2014-03-26 Thread Carlo Caione
Allwinner A20/A31 SoCs have special registers to control / (un)mask /
acknowledge NMI. This NMI controller is separated and independent from GIC.
This patch adds a new irqchip to manage NMI.

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 drivers/irqchip/Makefile|   1 +
 drivers/irqchip/irq-sunxi-nmi.c | 208 
 2 files changed, 209 insertions(+)
 create mode 100644 drivers/irqchip/irq-sunxi-nmi.c

diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 5194afb..1c0c151 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_METAG_PERFCOUNTER_IRQS)  += irq-metag.o
 obj-$(CONFIG_ARCH_MOXART)  += irq-moxart.o
 obj-$(CONFIG_ORION_IRQCHIP)+= irq-orion.o
 obj-$(CONFIG_ARCH_SUNXI)   += irq-sun4i.o
+obj-$(CONFIG_ARCH_SUNXI)   += irq-sunxi-nmi.o
 obj-$(CONFIG_ARCH_SPEAR3XX)+= spear-shirq.o
 obj-$(CONFIG_ARM_GIC)  += irq-gic.o
 obj-$(CONFIG_ARM_NVIC) += irq-nvic.o
diff --git a/drivers/irqchip/irq-sunxi-nmi.c b/drivers/irqchip/irq-sunxi-nmi.c
new file mode 100644
index 000..12f547a
--- /dev/null
+++ b/drivers/irqchip/irq-sunxi-nmi.c
@@ -0,0 +1,208 @@
+/*
+ * Allwinner A20/A31 SoCs NMI IRQ chip driver.
+ *
+ * Carlo Caione carlo.cai...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/bitops.h
+#include linux/device.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/interrupt.h
+#include linux/irqdomain.h
+#include linux/of_irq.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/irqchip/chained_irq.h
+#include irqchip.h
+
+#define SUNXI_NMI_SRC_TYPE_MASK0x0003
+
+enum {
+   SUNXI_SRC_TYPE_LEVEL_LOW = 0,
+   SUNXI_SRC_TYPE_EDGE_FALLING,
+   SUNXI_SRC_TYPE_LEVEL_HIGH,
+   SUNXI_SRC_TYPE_EDGE_RISING,
+};
+
+struct sunxi_sc_nmi_reg_offs {
+   u32 ctrl;
+   u32 pend;
+   u32 enable;
+};
+
+static struct sunxi_sc_nmi_reg_offs sun7i_reg_offs = {
+   .ctrl   = 0x00,
+   .pend   = 0x04,
+   .enable = 0x08,
+};
+
+static struct sunxi_sc_nmi_reg_offs sun6i_reg_offs = {
+   .ctrl   = 0x00,
+   .pend   = 0x04,
+   .enable = 0x34,
+};
+
+static inline void sunxi_sc_nmi_write(struct irq_chip_generic *gc, u32 off,
+ u32 val)
+{
+   irq_reg_writel(val, gc-reg_base + off);
+}
+
+static inline u32 sunxi_sc_nmi_read(struct irq_chip_generic *gc, u32 off)
+{
+   return irq_reg_readl(gc-reg_base + off);
+}
+
+static void sunxi_sc_nmi_handle_irq(unsigned int irq, struct irq_desc *desc)
+{
+   struct irq_domain *domain = irq_desc_get_handler_data(desc);
+   struct irq_chip *chip = irq_get_chip(irq);
+   unsigned int virq = irq_find_mapping(domain, 0);
+
+   chained_irq_enter(chip, desc);
+   generic_handle_irq(virq);
+   chained_irq_exit(chip, desc);
+}
+
+static int sunxi_sc_nmi_set_type(struct irq_data *data, unsigned int flow_type)
+{
+   struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
+   struct irq_chip_type *ct = gc-chip_types;
+   u32 src_type_reg;
+   u32 ctrl_off = ct-regs.type;
+   unsigned int src_type;
+   unsigned int i;
+
+   irq_gc_lock(gc);
+
+   switch (flow_type  IRQF_TRIGGER_MASK) {
+   case IRQ_TYPE_EDGE_FALLING:
+   src_type = SUNXI_SRC_TYPE_EDGE_FALLING;
+   break;
+   case IRQ_TYPE_EDGE_RISING:
+   src_type = SUNXI_SRC_TYPE_EDGE_RISING;
+   break;
+   case IRQ_TYPE_LEVEL_HIGH:
+   src_type = SUNXI_SRC_TYPE_LEVEL_HIGH;
+   break;
+   case IRQ_TYPE_NONE:
+   case IRQ_TYPE_LEVEL_LOW:
+   src_type = SUNXI_SRC_TYPE_LEVEL_LOW;
+   break;
+   default:
+   irq_gc_unlock(gc);
+   pr_err(%s: Cannot assign multiple trigger modes to IRQ %d.\n,
+   __func__, data-irq);
+   return -EBADR;
+   }
+
+   irqd_set_trigger_type(data, flow_type);
+   irq_setup_alt_chip(data, flow_type);
+
+   for (i = 0; i = gc-num_ct; i++, ct++)
+   if (ct-type  flow_type)
+   ctrl_off = ct-regs.type;
+
+   src_type_reg = sunxi_sc_nmi_read(gc, ctrl_off);
+   src_type_reg = ~SUNXI_NMI_SRC_TYPE_MASK;
+   src_type_reg |= src_type;
+   sunxi_sc_nmi_write(gc, ctrl_off, src_type_reg);
+
+   irq_gc_unlock(gc);
+
+   return IRQ_SET_MASK_OK;
+}
+
+static int __init sunxi_sc_nmi_irq_init(struct device_node *node,
+   struct sunxi_sc_nmi_reg_offs *reg_offs)
+{
+   struct irq_domain *domain;
+   struct irq_chip_generic *gc;
+   unsigned

[linux-sunxi] [PATCH v8 2/3] ARM: sun7i/sun6i: dts: Add NMI irqchip support

2014-03-26 Thread Carlo Caione
This patch adds DTS entries for NMI controller as child of GIC.

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 arch/arm/boot/dts/sun6i-a31.dtsi | 8 
 arch/arm/boot/dts/sun7i-a20.dtsi | 8 
 2 files changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index 42f310a..eb92353 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -237,6 +237,14 @@
#size-cells = 1;
ranges;
 
+   nmi_intc: interrupt-controller@01f00c0c {
+   compatible = allwinner,sun6i-a31-sc-nmi;
+   interrupt-controller;
+   #interrupt-cells = 2;
+   reg = 0x01f00c0c 0x38;
+   interrupts = 0 32 4;
+   };
+
pio: pinctrl@01c20800 {
compatible = allwinner,sun6i-a31-pinctrl;
reg = 0x01c20800 0x400;
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 4cc2f5f..843bd33 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -423,6 +423,14 @@
#size-cells = 0;
};
 
+   nmi_intc: interrupt-controller@01c00030 {
+   compatible = allwinner,sun7i-a20-sc-nmi;
+   interrupt-controller;
+   #interrupt-cells = 2;
+   reg = 0x01c00030 0x0c;
+   interrupts = 0 0 4;
+   };
+
emac: ethernet@01c0b000 {
compatible = allwinner,sun4i-a10-emac;
reg = 0x01c0b000 0x1000;
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v2 6/8] ARM: sunxi: dt: Add x-powers-axp209.dtsi file

2014-03-22 Thread Carlo Caione
On Tue, Mar 18, 2014 at 10:04:50AM +0100, Maxime Ripard wrote:
 On Sat, Mar 15, 2014 at 04:43:43PM +0100, Carlo Caione wrote:
  This dtsi describes the axp209 PMIC, and is to be included from inside
  the i2c controller node to which the axp209 is connected.
  
  Signed-off-by: Hans de Goede hdego...@redhat.com
  Signed-off-by: Carlo Caione ca...@caione.org
  ---
   arch/arm/boot/dts/x-powers-axp209.dtsi | 60 
  ++
   1 file changed, 60 insertions(+)
   create mode 100644 arch/arm/boot/dts/x-powers-axp209.dtsi
  
  diff --git a/arch/arm/boot/dts/x-powers-axp209.dtsi 
  b/arch/arm/boot/dts/x-powers-axp209.dtsi
  new file mode 100644
  index 000..d272e67
  --- /dev/null
  +++ b/arch/arm/boot/dts/x-powers-axp209.dtsi
  @@ -0,0 +1,60 @@
  +/*
  + * x-powers,axp209 common code to be include from inside the axp209 node
  + *
  + * Copyright 2014 - Carlo Caione ca...@caione.org
  + *
  + * The code contained herein is licensed under the GNU General Public
  + * License. You may obtain a copy of the GNU General Public License
  + * Version 2 or later at the following locations:
  + *
  + * http://www.opensource.org/licenses/gpl-license.html
  + * http://www.gnu.org/copyleft/gpl.html
  + */
  +
 
 I didn't even know such a thing was possible :)
 Nice hack.

Kudos to Hans ;)

 
  +   compatible = x-powers,axp209;
  +   interrupt-controller;
  +   #interrupt-cells = 1;
 
 However, I'd move this out of it, and in the board file, so that we
 actually get an idea by looking at the board DTS of what device we are
 actually registering at this given address, and what it's capable of.

Do you mean the whole dtsi or just those three lines?

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-03-22 Thread Carlo Caione
On Sat, Mar 22, 2014 at 11:42:01AM -0700, Dmitry Torokhov wrote:
 On Sat, Mar 22, 2014 at 07:13:36PM +0100, Carlo Caione wrote:
  On Sat, Mar 22, 2014 at 6:33 PM, Mark Brown broo...@kernel.org wrote:
   On Sat, Mar 22, 2014 at 05:51:32PM +0100, Carlo Caione wrote:
   On Tue, Mar 18, 2014 at 03:59:19PM +, Lee Jones wrote:
  
 + of_id = of_match_device(axp20x_of_match, i2c-dev);
 + if (!of_id) {
 + dev_err(i2c-dev, Unable to setup AXP20X data\n);
 + return -ENODEV;
 + }
 + axp20x-variant = (int) of_id-data;
  
No need to cast from void *.
  
   My compiler says otherwise :)
  
   Are you sure your compiler isn't correctly telling you not to cast away
   const?  If the compiler is complaining about a cast on void then it's
   spotted a definite bug.
  
  [resend since gmail decided to not put broonie in CC]
  
  drivers/mfd/axp20x.c:172:18: warning: assignment makes integer
  frompointer without a cast [enabled by default]
 
 You need to cast to long, otherwise you will get warnings when compiling
 on 64 bit arches.

Actually no warning also with (int) cast.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-03-22 Thread Carlo Caione
On Sat, Mar 22, 2014 at 6:33 PM, Mark Brown broo...@kernel.org wrote:
 On Sat, Mar 22, 2014 at 05:51:32PM +0100, Carlo Caione wrote:
 On Tue, Mar 18, 2014 at 03:59:19PM +, Lee Jones wrote:

   + of_id = of_match_device(axp20x_of_match, i2c-dev);
   + if (!of_id) {
   + dev_err(i2c-dev, Unable to setup AXP20X data\n);
   + return -ENODEV;
   + }
   + axp20x-variant = (int) of_id-data;

  No need to cast from void *.

 My compiler says otherwise :)

 Are you sure your compiler isn't correctly telling you not to cast away
 const?  If the compiler is complaining about a cast on void then it's
 spotted a definite bug.

[resend since gmail decided to not put broonie in CC]

drivers/mfd/axp20x.c:172:18: warning: assignment makes integer
frompointer without a cast [enabled by default]

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v6 0/3] ARM: sun7i/sun6i: irqchip: Irqchip driver for NMI controller

2014-03-19 Thread Carlo Caione
On Wed, Mar 19, 2014 at 1:41 PM, Thomas Gleixner t...@linutronix.de wrote:
 On Wed, 19 Mar 2014, Maxime Ripard wrote:

 On Wed, Mar 19, 2014 at 12:13:56PM +0100, Thomas Gleixner wrote:
  On Sat, 15 Mar 2014, Carlo Caione wrote:
 
   Allwinner A20/A31 SoCs have a special interrupt controller for managing 
   NMI.
   Three register are present to (un)mask, control and acknowledge NMI.
   These two patches add a new irqchip driver in cascade with GIC.
 
  If I get an ack for the DT parts, I'll pick it up.

 I had some comments on it, so Carlo will probably resubmit it.

 That's the resubmit as far as I can tell.

I'll submit a v7 addressing the Maxime's comments on DT part.

Regards,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v7 3/3] ARM: sun7i/sun6i: irqchip: Update the documentation

2014-03-19 Thread Carlo Caione
Added documentation for NMI irqchip.

Signed-off-by: Carlo Caione ca...@caione.org
---
 .../allwinner,sun67i-sc-nmi.txt| 27 ++
 1 file changed, 27 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt
 
b/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt
new file mode 100644
index 000..d1c5cda
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt
@@ -0,0 +1,27 @@
+Allwinner Sunxi NMI Controller
+==
+
+Required properties:
+
+- compatible : should be allwinner,sun7i-a20-sc-nmi or
+  allwinner,sun6i-a31-sc-nmi
+- reg : Specifies base physical address and size of the registers.
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells : Specifies the number of cells needed to encode an
+  interrupt source. The value shall be 2. The first cell is the IRQ number, the
+  second cell the trigger type as defined in interrupt.txt in this directory.
+- interrupt-parent: Specifies the parent interrupt controller.
+- interrupts: Specifies the interrupt line (NMI) which is handled by
+  the interrupt controller in the parent controller's notation. This value
+  shall be the NMI.
+
+Example:
+
+sc-nmi-intc@01c00030 {
+   compatible = allwinner,sun7i-a20-sc-nmi;
+   interrupt-controller;
+   #interrupt-cells = 2;
+   reg = 0x01c00030 0x0c;
+   interrupt-parent = gic;
+   interrupts = 0 0 4;
+};
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v7 2/3] ARM: sun7i/sun6i: dts: Add NMI irqchip support

2014-03-19 Thread Carlo Caione
This patch adds DTS entries for NMI controller as child of GIC.

Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/boot/dts/sun6i-a31.dtsi | 8 
 arch/arm/boot/dts/sun7i-a20.dtsi | 8 
 2 files changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index 5256ad9..eea6033 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -190,6 +190,14 @@
#size-cells = 1;
ranges;
 
+   nmi_intc: interrupt-controller@01f00c0c {
+   compatible = allwinner,sun6i-a31-sc-nmi;
+   interrupt-controller;
+   #interrupt-cells = 2;
+   reg = 0x01f00c0c 0x38;
+   interrupts = 0 0 4;
+   };
+
pio: pinctrl@01c20800 {
compatible = allwinner,sun6i-a31-pinctrl;
reg = 0x01c20800 0x400;
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 6f25cf5..7637f12 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -339,6 +339,14 @@
#size-cells = 1;
ranges;
 
+   nmi_intc: interrupt-controller@01c00030 {
+   compatible = allwinner,sun7i-a20-sc-nmi;
+   interrupt-controller;
+   #interrupt-cells = 2;
+   reg = 0x01c00030 0x0c;
+   interrupts = 0 0 4;
+   };
+
emac: ethernet@01c0b000 {
compatible = allwinner,sun4i-a10-emac;
reg = 0x01c0b000 0x1000;
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v7 1/3] ARM: sun7i/sun6i: irqchip: Add irqchip driver for NMI controller

2014-03-19 Thread Carlo Caione
Allwinner A20/A31 SoCs have special registers to control / (un)mask /
acknowledge NMI. This NMI controller is separated and independent from GIC.
This patch adds a new irqchip to manage NMI.

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 drivers/irqchip/Makefile|   1 +
 drivers/irqchip/irq-sunxi-nmi.c | 208 
 2 files changed, 209 insertions(+)
 create mode 100644 drivers/irqchip/irq-sunxi-nmi.c

diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 5194afb..1c0c151 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_METAG_PERFCOUNTER_IRQS)  += irq-metag.o
 obj-$(CONFIG_ARCH_MOXART)  += irq-moxart.o
 obj-$(CONFIG_ORION_IRQCHIP)+= irq-orion.o
 obj-$(CONFIG_ARCH_SUNXI)   += irq-sun4i.o
+obj-$(CONFIG_ARCH_SUNXI)   += irq-sunxi-nmi.o
 obj-$(CONFIG_ARCH_SPEAR3XX)+= spear-shirq.o
 obj-$(CONFIG_ARM_GIC)  += irq-gic.o
 obj-$(CONFIG_ARM_NVIC) += irq-nvic.o
diff --git a/drivers/irqchip/irq-sunxi-nmi.c b/drivers/irqchip/irq-sunxi-nmi.c
new file mode 100644
index 000..1c8566c
--- /dev/null
+++ b/drivers/irqchip/irq-sunxi-nmi.c
@@ -0,0 +1,208 @@
+/*
+ * Allwinner A20/A31 SoCs NMI IRQ chip driver.
+ *
+ * Carlo Caione carlo.cai...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/bitops.h
+#include linux/device.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/interrupt.h
+#include linux/irqdomain.h
+#include linux/of_irq.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/irqchip/chained_irq.h
+#include irqchip.h
+
+#define SUNXI_NMI_SRC_TYPE_MASK0x0003
+
+enum {
+   SUNXI_SRC_TYPE_LEVEL_LOW = 0,
+   SUNXI_SRC_TYPE_EDGE_FALLING,
+   SUNXI_SRC_TYPE_LEVEL_HIGH,
+   SUNXI_SRC_TYPE_EDGE_RISING,
+};
+
+struct sunxi_sc_nmi_reg_offs {
+   u32 ctrl;
+   u32 pend;
+   u32 enable;
+};
+
+static struct sunxi_sc_nmi_reg_offs sun7i_reg_offs = {
+   .ctrl   = 0x00,
+   .pend   = 0x04,
+   .enable = 0x08,
+};
+
+static struct sunxi_sc_nmi_reg_offs sun6i_reg_offs = {
+   .ctrl   = 0x00,
+   .pend   = 0x04,
+   .enable = 0x34,
+};
+
+static inline void sunxi_sc_nmi_write(struct irq_chip_generic *gc, u32 off,
+ u32 val)
+{
+   irq_reg_writel(val, gc-reg_base + off);
+}
+
+static inline u32 sunxi_sc_nmi_read(struct irq_chip_generic *gc, u32 off)
+{
+   return irq_reg_readl(gc-reg_base + off);
+}
+
+static void sunxi_sc_nmi_handle_irq(unsigned int irq, struct irq_desc *desc)
+{
+   struct irq_domain *domain = irq_desc_get_handler_data(desc);
+   struct irq_chip *chip = irq_get_chip(irq);
+   unsigned int virq = irq_find_mapping(domain, 0);
+
+   chained_irq_enter(chip, desc);
+   generic_handle_irq(virq);
+   chained_irq_exit(chip, desc);
+}
+
+static int sunxi_sc_nmi_set_type(struct irq_data *data, unsigned int flow_type)
+{
+   struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
+   struct irq_chip_type *ct = gc-chip_types;
+   u32 src_type_reg;
+   u32 ctrl_off = ct-regs.type;
+   unsigned int src_type;
+   unsigned int i;
+
+   irq_gc_lock(gc);
+
+   switch (flow_type  IRQF_TRIGGER_MASK) {
+   case IRQ_TYPE_EDGE_FALLING:
+   src_type = SUNXI_SRC_TYPE_EDGE_FALLING;
+   break;
+   case IRQ_TYPE_EDGE_RISING:
+   src_type = SUNXI_SRC_TYPE_EDGE_RISING;
+   break;
+   case IRQ_TYPE_LEVEL_HIGH:
+   src_type = SUNXI_SRC_TYPE_LEVEL_HIGH;
+   break;
+   case IRQ_TYPE_NONE:
+   case IRQ_TYPE_LEVEL_LOW:
+   src_type = SUNXI_SRC_TYPE_LEVEL_LOW;
+   break;
+   default:
+   irq_gc_unlock(gc);
+   pr_err(%s: Cannot assign multiple trigger modes to IRQ %d.\n,
+   __func__, data-irq);
+   return -EBADR;
+   }
+
+   irqd_set_trigger_type(data, flow_type);
+   irq_setup_alt_chip(data, flow_type);
+
+   for (i = 0; i = gc-num_ct; i++, ct++)
+   if (ct-type  flow_type)
+   ctrl_off = ct-regs.type;
+
+   src_type_reg = sunxi_sc_nmi_read(gc, ctrl_off);
+   src_type_reg = ~SUNXI_NMI_SRC_TYPE_MASK;
+   src_type_reg |= src_type;
+   sunxi_sc_nmi_write(gc, ctrl_off, src_type_reg);
+
+   irq_gc_unlock(gc);
+
+   return IRQ_SET_MASK_OK;
+}
+
+static int __init sunxi_sc_nmi_irq_init(struct device_node *node,
+   struct sunxi_sc_nmi_reg_offs *reg_offs)
+{
+   struct irq_domain *domain;
+   struct irq_chip_generic *gc;
+   unsigned

[linux-sunxi] [PATCH v6 0/3] ARM: sun7i/sun6i: irqchip: Irqchip driver for NMI controller

2014-03-15 Thread Carlo Caione
Allwinner A20/A31 SoCs have a special interrupt controller for managing NMI.
Three register are present to (un)mask, control and acknowledge NMI.
These two patches add a new irqchip driver in cascade with GIC.

Changes since v1:
- added binding document

Changes since v2:
- fixed trigger type in DTS
- new explanations in binding documentation
- added support for A31 (sun6i)

Changes since v3:
- changed compatibles

Changes since v4:
- fixed binding documentation

Changes since v5:
- switched to handle_fasteoi_irq handler to avoid the double
  interrupts issue

Carlo Caione (3):
  ARM: sun7i/sun6i: irqchip: Add irqchip driver for NMI controller
  ARM: sun7i/sun6i: dts: Add NMI irqchip support
  ARM: sun7i/sun6i: irqchip: Update the documentation

 .../allwinner,sun67i-sc-nmi.txt|  27 +++
 arch/arm/boot/dts/sun6i-a31.dtsi   |   9 +
 arch/arm/boot/dts/sun7i-a20.dtsi   |   9 +
 drivers/irqchip/Makefile   |   1 +
 drivers/irqchip/irq-sunxi-nmi.c| 208 +
 5 files changed, 254 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt
 create mode 100644 drivers/irqchip/irq-sunxi-nmi.c

-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v6 1/3] ARM: sun7i/sun6i: irqchip: Add irqchip driver for NMI controller

2014-03-15 Thread Carlo Caione
Allwinner A20/A31 SoCs have special registers to control / (un)mask /
acknowledge NMI. This NMI controller is separated and independent from GIC.
This patch adds a new irqchip to manage NMI.

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 drivers/irqchip/Makefile|   1 +
 drivers/irqchip/irq-sunxi-nmi.c | 208 
 2 files changed, 209 insertions(+)
 create mode 100644 drivers/irqchip/irq-sunxi-nmi.c

diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 5194afb..1c0c151 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_METAG_PERFCOUNTER_IRQS)  += irq-metag.o
 obj-$(CONFIG_ARCH_MOXART)  += irq-moxart.o
 obj-$(CONFIG_ORION_IRQCHIP)+= irq-orion.o
 obj-$(CONFIG_ARCH_SUNXI)   += irq-sun4i.o
+obj-$(CONFIG_ARCH_SUNXI)   += irq-sunxi-nmi.o
 obj-$(CONFIG_ARCH_SPEAR3XX)+= spear-shirq.o
 obj-$(CONFIG_ARM_GIC)  += irq-gic.o
 obj-$(CONFIG_ARM_NVIC) += irq-nvic.o
diff --git a/drivers/irqchip/irq-sunxi-nmi.c b/drivers/irqchip/irq-sunxi-nmi.c
new file mode 100644
index 000..1c8566c
--- /dev/null
+++ b/drivers/irqchip/irq-sunxi-nmi.c
@@ -0,0 +1,208 @@
+/*
+ * Allwinner A20/A31 SoCs NMI IRQ chip driver.
+ *
+ * Carlo Caione carlo.cai...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/bitops.h
+#include linux/device.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/interrupt.h
+#include linux/irqdomain.h
+#include linux/of_irq.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/irqchip/chained_irq.h
+#include irqchip.h
+
+#define SUNXI_NMI_SRC_TYPE_MASK0x0003
+
+enum {
+   SUNXI_SRC_TYPE_LEVEL_LOW = 0,
+   SUNXI_SRC_TYPE_EDGE_FALLING,
+   SUNXI_SRC_TYPE_LEVEL_HIGH,
+   SUNXI_SRC_TYPE_EDGE_RISING,
+};
+
+struct sunxi_sc_nmi_reg_offs {
+   u32 ctrl;
+   u32 pend;
+   u32 enable;
+};
+
+static struct sunxi_sc_nmi_reg_offs sun7i_reg_offs = {
+   .ctrl   = 0x00,
+   .pend   = 0x04,
+   .enable = 0x08,
+};
+
+static struct sunxi_sc_nmi_reg_offs sun6i_reg_offs = {
+   .ctrl   = 0x00,
+   .pend   = 0x04,
+   .enable = 0x34,
+};
+
+static inline void sunxi_sc_nmi_write(struct irq_chip_generic *gc, u32 off,
+ u32 val)
+{
+   irq_reg_writel(val, gc-reg_base + off);
+}
+
+static inline u32 sunxi_sc_nmi_read(struct irq_chip_generic *gc, u32 off)
+{
+   return irq_reg_readl(gc-reg_base + off);
+}
+
+static void sunxi_sc_nmi_handle_irq(unsigned int irq, struct irq_desc *desc)
+{
+   struct irq_domain *domain = irq_desc_get_handler_data(desc);
+   struct irq_chip *chip = irq_get_chip(irq);
+   unsigned int virq = irq_find_mapping(domain, 0);
+
+   chained_irq_enter(chip, desc);
+   generic_handle_irq(virq);
+   chained_irq_exit(chip, desc);
+}
+
+static int sunxi_sc_nmi_set_type(struct irq_data *data, unsigned int flow_type)
+{
+   struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
+   struct irq_chip_type *ct = gc-chip_types;
+   u32 src_type_reg;
+   u32 ctrl_off = ct-regs.type;
+   unsigned int src_type;
+   unsigned int i;
+
+   irq_gc_lock(gc);
+
+   switch (flow_type  IRQF_TRIGGER_MASK) {
+   case IRQ_TYPE_EDGE_FALLING:
+   src_type = SUNXI_SRC_TYPE_EDGE_FALLING;
+   break;
+   case IRQ_TYPE_EDGE_RISING:
+   src_type = SUNXI_SRC_TYPE_EDGE_RISING;
+   break;
+   case IRQ_TYPE_LEVEL_HIGH:
+   src_type = SUNXI_SRC_TYPE_LEVEL_HIGH;
+   break;
+   case IRQ_TYPE_NONE:
+   case IRQ_TYPE_LEVEL_LOW:
+   src_type = SUNXI_SRC_TYPE_LEVEL_LOW;
+   break;
+   default:
+   irq_gc_unlock(gc);
+   pr_err(%s: Cannot assign multiple trigger modes to IRQ %d.\n,
+   __func__, data-irq);
+   return -EBADR;
+   }
+
+   irqd_set_trigger_type(data, flow_type);
+   irq_setup_alt_chip(data, flow_type);
+
+   for (i = 0; i = gc-num_ct; i++, ct++)
+   if (ct-type  flow_type)
+   ctrl_off = ct-regs.type;
+
+   src_type_reg = sunxi_sc_nmi_read(gc, ctrl_off);
+   src_type_reg = ~SUNXI_NMI_SRC_TYPE_MASK;
+   src_type_reg |= src_type;
+   sunxi_sc_nmi_write(gc, ctrl_off, src_type_reg);
+
+   irq_gc_unlock(gc);
+
+   return IRQ_SET_MASK_OK;
+}
+
+static int __init sunxi_sc_nmi_irq_init(struct device_node *node,
+   struct sunxi_sc_nmi_reg_offs *reg_offs)
+{
+   struct irq_domain *domain;
+   struct irq_chip_generic *gc;
+   unsigned

[linux-sunxi] [PATCH v2 8/8] ARM: sunxi: Add AXP20x support in defconfig

2014-03-15 Thread Carlo Caione
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/configs/sunxi_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig
index 3e2259b..0cef101 100644
--- a/arch/arm/configs/sunxi_defconfig
+++ b/arch/arm/configs/sunxi_defconfig
@@ -39,6 +39,8 @@ CONFIG_SUN4I_EMAC=y
 # CONFIG_NET_VENDOR_STMICRO is not set
 # CONFIG_NET_VENDOR_WIZNET is not set
 # CONFIG_WLAN is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=8
@@ -52,6 +54,7 @@ CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
 CONFIG_SUNXI_WATCHDOG=y
+CONFIG_MFD_AXP20X=y
 # CONFIG_USB_SUPPORT is not set
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
@@ -66,3 +69,4 @@ CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
 CONFIG_NLS=y
 CONFIG_PRINTK_TIME=y
+CONFIG_REGULATOR_AXP20X=y
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v2 2/8] mfd: AXP20x: Add bindings documentation

2014-03-15 Thread Carlo Caione
Bindings documentation for the AXP20x driver. In this file also two
sub-nodes (PEK and regulators) are documented.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/devicetree/bindings/mfd/axp20x.txt   | 83 ++
 .../devicetree/bindings/vendor-prefixes.txt|  1 +
 2 files changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt 
b/Documentation/devicetree/bindings/mfd/axp20x.txt
new file mode 100644
index 000..982aefe
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -0,0 +1,83 @@
+* axp20x device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible   : Should be x-powers,axp202 or 
x-powers,axp209
+- interrupt-controller : axp20x has its own internal IRQs
+- #interrupt-cells : Should be set to 1
+- interrupt-parent : The parent interrupt controller
+- interrupts   : Interrupt specifiers for interrupt sources
+- reg  : The I2C slave address for the AXP chip
+
+Sub-nodes:
+* regulators : Contain the regulator nodes. The regulators are bound using
+  their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3,
+  ldo4, ldo5.
+  The bindings details of individual regulator device can be found 
in:
+  Documentation/devicetree/bindings/regulator/regulator.txt with 
the
+  exception of:
+
+   - dcdc-freq : defines the work frequency of DC-DC in KHz
+ (range: 750-1875). Default: 1.5MHz
+   - dcdc-workmode : Optional. 1 for PWM mode, 0 for AUTO mode
+ Default: AUTO mode
+
+Example:
+
+axp: axp20x@34 {
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   compatible = x-powers,axp209;
+   interrupt-controller;
+   #interrupt-cells = 1;
+
+   regulators {
+   dcdc-freq = 1500;
+
+   axp_dcdc2: dcdc2 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 2275000;
+   dcdc-workmode = 0;
+   regulator-always-on;
+   };
+
+   axp_dcdc3: dcdc3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   dcdc-workmode = 0;
+   regulator-always-on;
+   };
+
+   axp_ldo1: ldo1 {
+   regulator-min-microvolt = 130;
+   regulator-max-microvolt = 130;
+   };
+
+   axp_ldo2: ldo2 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   regulator-always-on;
+   };
+
+   axp_ldo3: ldo3 {
+   regulator-min-microvolt = 70;
+   regulator-max-microvolt = 350;
+   };
+
+   axp_ldo4: ldo4 {
+   regulator-min-microvolt = 125;
+   regulator-max-microvolt = 330;
+   };
+
+   axp_ldo5: ldo5 {
+   regulator-min-microvolt = 180;
+   regulator-max-microvolt = 330;
+   };
+   };
+};
+
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 40ce2df..d06ba8c 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -95,3 +95,4 @@ winbond Winbond Electronics corp.
 wlfWolfson Microelectronics
 wm Wondermedia Technologies, Inc.
 xlnx   Xilinx
+x-powers   X-Powers
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v2 4/8] input: misc: Add ABI docs for AXP20x PEK

2014-03-15 Thread Carlo Caione
Add ABI entries for the PEK found on PMU X-Powers AXP202 and AXP209.

Signed-off-by: Carlo Caione ca...@caione.org
---
 Documentation/ABI/testing/sysfs-driver-input-axp-pek | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek

diff --git a/Documentation/ABI/testing/sysfs-driver-input-axp-pek 
b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
new file mode 100644
index 000..f8cdad2
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
@@ -0,0 +1,11 @@
+What:  /sys/class/input/input(x)/startup
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Startup time. Board is powered on if the button is pressed
+   for more than startup_time
+
+What:  /sys/class/input/input(x)/shutdown
+Date:  March 2014
+Contact:   Carlo Caione ca...@caione.org
+Description:   Shutdown time. Board is powered off if the button is pressed
+   for more than shutdown_time
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-03-15 Thread Carlo Caione
This patch introduces the preliminary support for PMICs X-Powers AXP202
and AXP209. The AXP209 and AXP202 are the PMUs (Power Management Unit)
used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company
of Allwinner.

The core enables support for two subsystems:
- PEK (Power Enable Key)
- Regulators

Signed-off-by: Carlo Caione ca...@caione.org
---
 drivers/mfd/Kconfig|  12 +++
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/axp20x.c   | 247 +
 include/linux/mfd/axp20x.h | 179 
 4 files changed, 439 insertions(+)
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 include/linux/mfd/axp20x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 49bb445..24ba61a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -59,6 +59,18 @@ config MFD_AAT2870_CORE
  additional drivers must be enabled in order to use the
  functionality of the device.
 
+config MFD_AXP20X
+   bool X-Powers AXP20X
+   select MFD_CORE
+   select REGMAP_I2C
+   select REGMAP_IRQ
+   depends on I2C=y
+   help
+ If you say Y here you get support for the AXP20X.
+ This driver provides common support for accessing the device,
+ additional drivers must be enabled in order to use the
+ functionality of the device.
+
 config MFD_CROS_EC
tristate ChromeOS Embedded Controller
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 5aea5ef..fb773b5 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -101,6 +101,7 @@ obj-$(CONFIG_PMIC_DA9052)   += da9052-irq.o
 obj-$(CONFIG_PMIC_DA9052)  += da9052-core.o
 obj-$(CONFIG_MFD_DA9052_SPI)   += da9052-spi.o
 obj-$(CONFIG_MFD_DA9052_I2C)   += da9052-i2c.o
+obj-$(CONFIG_MFD_AXP20X)   += axp20x.o
 
 obj-$(CONFIG_MFD_LP3943)   += lp3943.o
 obj-$(CONFIG_MFD_LP8788)   += lp8788.o lp8788-irq.o
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
new file mode 100644
index 000..a790f0f
--- /dev/null
+++ b/drivers/mfd/axp20x.c
@@ -0,0 +1,247 @@
+/*
+ * axp20x.c - mfd core driver for the X-Powers AXP202 and AXP209
+ *
+ * Author: Carlo Caione ca...@caione.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/err.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/pm_runtime.h
+#include linux/regmap.h
+#include linux/slab.h
+#include linux/regulator/consumer.h
+#include linux/mfd/axp20x.h
+#include linux/mfd/core.h
+#include linux/of_device.h
+#include linux/of_irq.h
+
+#define AXP20X_OFF 0x80
+
+static const struct regmap_range axp20x_writeable_ranges[] = {
+   regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
+   regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
+};
+
+static const struct regmap_range axp20x_volatile_ranges[] = {
+   regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
+};
+
+static const struct regmap_access_table axp20x_writeable_table = {
+   .yes_ranges = axp20x_writeable_ranges,
+   .n_yes_ranges   = ARRAY_SIZE(axp20x_writeable_ranges),
+};
+
+static const struct regmap_access_table axp20x_volatile_table = {
+   .yes_ranges = axp20x_volatile_ranges,
+   .n_yes_ranges   = ARRAY_SIZE(axp20x_volatile_ranges),
+};
+
+static struct resource axp20x_pek_resources[] = {
+   {
+   .name   = PEK_DBR,
+   .start  = AXP20X_IRQ_PEK_RIS_EDGE,
+   .end= AXP20X_IRQ_PEK_RIS_EDGE,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .name   = PEK_DBF,
+   .start  = AXP20X_IRQ_PEK_FAL_EDGE,
+   .end= AXP20X_IRQ_PEK_FAL_EDGE,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static const struct regmap_config axp20x_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .wr_table   = axp20x_writeable_table,
+   .volatile_table = axp20x_volatile_table,
+   .max_register   = AXP20X_FG_RES,
+   .cache_type = REGCACHE_RBTREE,
+};
+
+#define AXP20X_IRQ(_irq, _off, _mask) \
+   [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
+
+static const struct regmap_irq axp20x_regmap_irqs[] = {
+   AXP20X_IRQ(ACIN_OVER_V, 0, 7),
+   AXP20X_IRQ(ACIN_PLUGIN, 0, 6),
+   AXP20X_IRQ(ACIN_REMOVAL,0, 5),
+   AXP20X_IRQ(VBUS_OVER_V, 0, 4),
+   AXP20X_IRQ(VBUS_PLUGIN, 0, 3),
+   AXP20X_IRQ(VBUS_REMOVAL,0, 2),
+   AXP20X_IRQ(VBUS_V_LOW,  0, 1),
+   AXP20X_IRQ(BATT_PLUGIN, 1, 7),
+   AXP20X_IRQ(BATT_REMOVAL,1, 6),
+   AXP20X_IRQ(BATT_ENT_ACT_MODE,   1, 5),
+   AXP20X_IRQ(BATT_EXIT_ACT_MODE,  1, 4

[linux-sunxi] [PATCH v2 7/8] ARM: sun7i: dt: Add AXP209 support to various boards

2014-03-15 Thread Carlo Caione
Signed-off-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Carlo Caione ca...@caione.org
---
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 12 
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts  | 13 +
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 12 
 3 files changed, 37 insertions(+)

diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
index 5c51cb8..9ad7da5 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
@@ -53,6 +53,18 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   axp: axp20x@34 {
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   axp,system-power-controller;
+
+   /include/ x-powers-axp209.dtsi
+   };
};
 
i2c1: i2c@01c2b000 {
diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
index f9dcb61..aab77f9 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
@@ -38,6 +38,19 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   axp: axp20x@34 {
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   axp,system-power-controller;
+
+   /include/ x-powers-axp209.dtsi
+   };
+
};
 
i2c1: i2c@01c2b000 {
diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts 
b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
index ead3013..a5fe5d0 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
@@ -65,6 +65,18 @@
pinctrl-names = default;
pinctrl-0 = i2c0_pins_a;
status = okay;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   axp: axp20x@34 {
+   reg = 0x34;
+   interrupt-parent = nmi_intc;
+   interrupts = 0 8;
+
+   axp,system-power-controller;
+
+   /include/ x-powers-axp209.dtsi
+   };
};
 
i2c1: i2c@01c2b000 {
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v2 0/8] mfd: AXP20x: Add support for AXP202 and AXP209

2014-03-15 Thread Carlo Caione
AXP209 and AXP202 are the PMUs (Power Management Unit) used by A10, A13
and A20 SoCs and developed by X-Powers, a sister company of Allwinner.
AXP20x comprises an adaptive USB-Compatible PWM charger, 2 BUCK DC-DC
converters, 5 LDOs, multiple 12-bit ADCs of voltage, current and temperature
as well as 4 configurable GPIOs. 

This set of patches introduces the core driver and support for two different
subsystems:
- Regulators
- PEK (Power Enable Key)

This patchset depends on patchsets:
irq: sun4i IRQ 0 / ENMI fixes (Hans de Goede)
ARM: sun7i/sun6i: irqchip: Irqchip driver for NMI controller (Carlo 
Caione)

Changes since v1:
- Added a new standalone patch for defconfig

- MFD core:
  * Removed axp,system-power-controller property

- Bindings documentation:
  * Corrected description for dcdc-workmode property
  * Removed unused axp20x-pek compatible

- Input misc PEK driver:
  * Fixed seconds in lower case

- Regulators subsystem:
  * Fixed axp20x_set_suspend_voltage()
  * Switched to using multi-bit control for regulators
  * When regulators node is not found driver doesn't quit
  * Driver is now using devm_regulator_register()
  * Added module_platform_driver() instead of subsys_initcall()

- DT:
  * Added new DTSI for AXP209
  * Added support for cubietruck and olinuxino-micro

Carlo Caione (8):
  mfd: AXP20x: Add mfd driver for AXP20x PMIC
  mfd: AXP20x: Add bindings documentation
  input: misc: Add driver for AXP20x Power Enable Key
  input: misc: Add ABI docs for AXP20x PEK
  regulator: AXP20x: Add support for regulators subsystem
  ARM: sunxi: dt: Add x-powers-axp209.dtsi file
  ARM: sun7i: dt: Add AXP209 support to various boards
  ARM: sunxi: Add AXP20x support in defconfig

 .../ABI/testing/sysfs-driver-input-axp-pek |  11 +
 Documentation/devicetree/bindings/mfd/axp20x.txt   |  83 ++
 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts|  12 +
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts |  13 +
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts|  12 +
 arch/arm/boot/dts/x-powers-axp209.dtsi |  60 +
 arch/arm/configs/sunxi_defconfig   |   4 +
 drivers/input/misc/Kconfig |  11 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/axp20x-pek.c| 267 +++
 drivers/mfd/Kconfig|  12 +
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/axp20x.c   | 247 +
 drivers/regulator/Kconfig  |   7 +
 drivers/regulator/Makefile |   1 +
 drivers/regulator/axp20x-regulator.c   | 293 +
 include/linux/mfd/axp20x.h | 179 +
 18 files changed, 1215 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
 create mode 100644 arch/arm/boot/dts/x-powers-axp209.dtsi
 create mode 100644 drivers/input/misc/axp20x-pek.c
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 drivers/regulator/axp20x-regulator.c
 create mode 100644 include/linux/mfd/axp20x.h

-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] [PATCH v2 5/8] regulator: AXP20x: Add support for regulators subsystem

2014-03-15 Thread Carlo Caione
AXP202 and AXP209 come with two synchronous step-down DC-DCs and five
LDOs. This patch introduces basic support for those regulators.

Signed-off-by: Carlo Caione ca...@caione.org
---
 drivers/regulator/Kconfig|   7 +
 drivers/regulator/Makefile   |   1 +
 drivers/regulator/axp20x-regulator.c | 293 +++
 3 files changed, 301 insertions(+)
 create mode 100644 drivers/regulator/axp20x-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 6a79328..9f3bc48 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -139,6 +139,13 @@ config REGULATOR_AS3722
  AS3722 PMIC. This will enable support for all the software
  controllable DCDC/LDO regulators.
 
+config REGULATOR_AXP20X
+   tristate X-POWERS AXP20X PMIC Regulators
+   depends on MFD_AXP20X
+   help
+ This driver provides support for the voltage regulators on the
+ AXP20X PMIC.
+
 config REGULATOR_DA903X
tristate Dialog Semiconductor DA9030/DA9034 regulators
depends on PMIC_DA903X
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 979f9dd..1dd084a 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
 obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
+obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
 obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
 obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
diff --git a/drivers/regulator/axp20x-regulator.c 
b/drivers/regulator/axp20x-regulator.c
new file mode 100644
index 000..f09fe35
--- /dev/null
+++ b/drivers/regulator/axp20x-regulator.c
@@ -0,0 +1,293 @@
+/*
+ * AXP20x regulators driver.
+ *
+ * Copyright (C) 2013 Carlo Caione ca...@caione.org
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/err.h
+#include linux/init.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/mfd/axp20x.h
+#include linux/regulator/driver.h
+#include linux/regulator/of_regulator.h
+
+#define AXP20X_IO_ENABLED  (0x03)
+#define AXP20X_IO_DISABLED (0x07)
+
+#define AXP20X_WORKMODE_DCDC2_MASK BIT(2)
+#define AXP20X_WORKMODE_DCDC3_MASK BIT(1)
+
+#define AXP20X_FREQ_DCDC_MASK  (0x0f)
+
+struct axp20x_regulators {
+   struct regulator_desc   rdesc[AXP20X_REG_ID_MAX];
+   struct regulator_dev*rdev[AXP20X_REG_ID_MAX];
+   struct axp20x_dev   *axp20x;
+};
+
+#define AXP20X_DESC_IO(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask,   
\
+  _enable_val, _disable_val)   
\
+   [AXP20X_##_id] = {  
\
+   .name   = #_id, 
\
+   .type   = REGULATOR_VOLTAGE,
\
+   .id = AXP20X_##_id, 
\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),
\
+   .owner  = THIS_MODULE,  
\
+   .min_uV = (_min) * 1000,
\
+   .uV_step= (_step) * 1000,   
\
+   .vsel_reg   = (_vreg),  
\
+   .vsel_mask  = (_vmask), 
\
+   .enable_reg = (_ereg),  
\
+   .enable_mask= (_emask), 
\
+   .enable_val = (_enable_val),
\
+   .disable_val= (_disable_val),   
\
+   .ops= axp20x_ops,  
\
+   }
+
+#define AXP20X_DESC(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask)  
\
+   AXP20X_DESC_IO(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask,
\
+  0, 0)
+
+#define AXP20X_DESC_FIXED(_id, _volt)  
\
+   [AXP20X_##_id] = {  
\
+   .name

Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-09 Thread Carlo Caione
On Sun, Mar 09, 2014 at 07:51:48AM +, Mark Brown wrote:
 On Sat, Mar 08, 2014 at 12:43:04PM +0100, Carlo Caione wrote:
  On Fri, Mar 7, 2014 at 7:22 PM, Maxime Ripard
   On Sat, Mar 01, 2014 at 05:45:51PM +0100, Carlo Caione wrote:
 
   + return platform_driver_register(axp20x_regulator_driver);
 
   I thought the AXP was only connected through I2C? How is that a
   platform device then?
 
  Not really. It is plain wrong.
  I'll fix it in v2.
 
 Are you sure this is wrong?  For MFDs the core MFD is a driver of
 whatever bus type is in use but the function drivers are platform
 devices which talk to the hardware via the core device.

ok, I spoke too soon. Sorry for the noise.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 2/7] mfd: AXP20x: Add bindings documentation

2014-03-08 Thread Carlo Caione
On Fri, Mar 07, 2014 at 07:13:00PM +0100, Maxime Ripard wrote:
 On Sat, Mar 01, 2014 at 05:45:47PM +0100, Carlo Caione wrote:
  Bindings documentation for the AXP20x driver. In this file also two
  sub-nodes (PEK and regulators) are documented.
  
  Signed-off-by: Carlo Caione ca...@caione.org
  ---
   Documentation/devicetree/bindings/mfd/axp20x.txt | 93 
  
   1 file changed, 93 insertions(+)
   create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
  
  diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt 
  b/Documentation/devicetree/bindings/mfd/axp20x.txt
  new file mode 100644
  index 000..ae3e3c4
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
  @@ -0,0 +1,93 @@
  +* axp20x device tree bindings
  +
  +The axp20x family current members :-
  +axp202 (X-Powers)
  +axp209 (X-Powers)
  +
  +Required properties:
  +- compatible   : Should be x-powers,axp202 or 
  x-powers,axp209
  +- interrupt-controller : axp20x has its own internal IRQs
  +- #interrupt-cells : Should be set to 1
  +- interrupt-parent : The parent interrupt controller
  +- interrupts   : Interrupt specifiers for interrupt 
  sources
  +- reg  : The I2C slave address for the AXP chip
  +- axp,system-power-controller  : Telling whether or not this pmic is
  + controlling the system power
  +
  +Sub-nodes:
  +* regulators : Contain the regulator nodes. The regulators are bound using
  +  their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3,
  +  ldo4, ldo5.
  +  The bindings details of individual regulator device can be found 
  in:
  +  Documentation/devicetree/bindings/regulator/regulator.txt with 
  the
  +  exception of:
  +
  +   - dcdc-freq : defines the work frequency of DC-DC in KHz
  + (range: 750-1875)
  +   - dcdc-workmode : 1 for PWM mode, 0 for AUTO mode
 
 You don't seem to always set this. You should mention that it is
 optional, and which default value it has.

Fix in v2.

  +
  +* axp20x-pek : Power Enable Key
  +   - compatible: should be x-powers,axp20x-pek
 
 Why is this needed for?
 
 Plus, please don't use any generic, or pattern matching compatibles,
 but rather precise ones, so that if it is needed, we can add any quirk
 we want.

It is not needed, in fact I deleted it from dts. It is a refuse from the
previous submission. I'll fix it.

  +Example:
  +
  +axp: axp20x@34 {
  +   reg = 0x34;
  +   interrupt-parent = nmi_intc;
  +   interrupts = 0 8;
  +
  +   axp,system-power-controller;
  +
  +   compatible = x-powers,axp209;
  +   interrupt-controller;
  +   #interrupt-cells = 1;
  +
  +   axp20x-pek {
  +   compatible = x-powers,axp20x-pek;
  +   };
  +
  +   regulators {
  +   dcdc-freq = 8;
  +
  +   axp_dcdc2: dcdc2 {
  +   regulator-min-microvolt = 70;
  +   regulator-max-microvolt = 2275000;
  +   dcdc-workmode = 0;
  +   regulator-always-on;
  +   };
  +
  +   axp_dcdc3: dcdc3 {
  +   regulator-min-microvolt = 70;
  +   regulator-max-microvolt = 350;
  +   dcdc-workmode = 0;
  +   regulator-always-on;
  +   };
  +
  +   axp_ldo1: ldo1 {
  +   regulator-min-microvolt = 130;
  +   regulator-max-microvolt = 130;
  +   };
  +
  +   axp_ldo2: ldo2 {
  +   regulator-min-microvolt = 180;
  +   regulator-max-microvolt = 330;
  +   regulator-always-on;
  +   };
  +
  +   axp_ldo3: ldo3 {
  +   regulator-min-microvolt = 70;
  +   regulator-max-microvolt = 350;
  +   };
  +
  +   axp_ldo4: ldo4 {
  +   regulator-min-microvolt = 125;
  +   regulator-max-microvolt = 330;
  +   };
  +
  +   axp_ldo5: ldo5 {
  +   regulator-min-microvolt = 180;
  +   regulator-max-microvolt = 330;
  +   };
  +   };
  +};
  +
  -- 
  1.8.3.2
  

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-08 Thread Carlo Caione
On Fri, Mar 7, 2014 at 7:22 PM, Maxime Ripard
maxime.rip...@free-electrons.com wrote:
 On Sat, Mar 01, 2014 at 05:45:51PM +0100, Carlo Caione wrote:
 +static struct platform_driver axp20x_regulator_driver = {
 + .probe  = axp20x_regulator_probe,
 + .remove = axp20x_regulator_remove,
 + .driver = {
 + .name   = axp20x-regulator,
 + .owner  = THIS_MODULE,
 + },
 +};
 +
 +static int __init axp20x_regulator_init(void)
 +{
 + return platform_driver_register(axp20x_regulator_driver);
 +}
 +
 +subsys_initcall(axp20x_regulator_init);

 Hmmm, really?

 I thought the AXP was only connected through I2C? How is that a
 platform device then?

Not really. It is plain wrong.
I'll fix it in v2.

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: Build sunxi-next for A20

2014-03-06 Thread Carlo Caione
On Thu, Mar 6, 2014 at 9:39 AM,  hmandevt...@gmail.com wrote:
 And dtb?
 i followed a part of this guide (kernel build and Write kernel uImage you 
 build to the sd)
 http://olimex.wordpress.com/2013/11/05/building-the-ultimate-debian-sd-card-for-linux-with-kernel-3-4-for-a20-olinuxino-micro/

 and i haven't found dtb

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x40008000 -j4 dtbs

As clearly written in  http://linux-sunxi.org/Mainline_Kernel_Howto

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [linux-sunxi] Re: Build sunxi-next for A20

2014-03-06 Thread Carlo Caione
On Thu, Mar 6, 2014 at 10:25 AM,  hmandevt...@gmail.com wrote:
 Hi Carlo,
 sorry but it's my first time to build kernel on ARM board :)

 i generated sun7i-a20-olinuxino-micro.dtb/dts and copied into boot partition 
 as uImage but at boot i don't see any console to U-boot prompt.

 I'm using HDMI video output

I guess you should switch to using a serial output to be able to see
the U-Boot prompt especially with mainline kernel (for which is IIRC
is required to have a UART access)

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [linux-sunxi] Re: [PATCH 0/7] mfd: AXP20x: Add support for AXP202 and AXP209

2014-03-06 Thread Carlo Caione
On Thu, Mar 6, 2014 at 11:07 AM, Hans de Goede hdego...@redhat.com wrote:
 Hi,

 On 03/05/2014 09:46 PM, Carlo Caione wrote:
 On Wed, Mar 5, 2014 at 9:02 PM, Hans de Goede hdego...@redhat.com wrote:

 So I've added your patches to my sunxi-devel tree and they work as 
 advertised :)

 Thank you for keeping the tree updated :)

 I've also added dt support for the axp209 to the cubietruck dts file, to 
 avoid
 things becoming a copy and paste fest I've introduced a new axp209.dtsi 
 file,
 as well as did some fixes to the existing sun?i-a*.dtsi files, see my tree 
 here:
 https://github.com/jwrdegoede/linux-sunxi/commits/sunxi-devel

 That was also my idea (creating a new axp20x.dtsi) but it has been
 turned down by Maxime and Lee

 Hmm, do you have a pointer to the mailinglist discussion about this ?

Sure, http://www.spinics.net/lists/arm-kernel/msg306497.html

Best,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [linux-sunxi] Re: [PATCH 0/7] mfd: AXP20x: Add support for AXP202 and AXP209

2014-03-06 Thread Carlo Caione
On Thu, Mar 6, 2014 at 12:05 PM, Hans de Goede hdego...@redhat.com wrote:

 Ah, yes but that is before you added all the regulators, which are a fixed 
 part
 of the chip. Once you get long dts bits like that having a dtsi file makes a 
 lot
 of sense IMHO. Note that the part of the dts this was discussing is actually 
 the part
 I did not put in the dtis, since it can vary per board :)

Oook, now it makes sense. The idea was to integrate axp20x.dtsi at a
later time, but probably I was misunderstood. Thank you for clarifying
it.
I'll put axp20x.dtsi back in v2.

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[linux-sunxi] [PATCH v5 3/3] ARM: sun7i/sun6i: irqchip: Update the documentation

2014-03-05 Thread Carlo Caione
Added documentation for NMI irqchip.

Signed-off-by: Carlo Caione ca...@caione.org
---
 .../allwinner,sun67i-sc-nmi.txt| 27 ++
 1 file changed, 27 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt
 
b/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt
new file mode 100644
index 000..d1c5cda
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun67i-sc-nmi.txt
@@ -0,0 +1,27 @@
+Allwinner Sunxi NMI Controller
+==
+
+Required properties:
+
+- compatible : should be allwinner,sun7i-a20-sc-nmi or
+  allwinner,sun6i-a31-sc-nmi
+- reg : Specifies base physical address and size of the registers.
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells : Specifies the number of cells needed to encode an
+  interrupt source. The value shall be 2. The first cell is the IRQ number, the
+  second cell the trigger type as defined in interrupt.txt in this directory.
+- interrupt-parent: Specifies the parent interrupt controller.
+- interrupts: Specifies the interrupt line (NMI) which is handled by
+  the interrupt controller in the parent controller's notation. This value
+  shall be the NMI.
+
+Example:
+
+sc-nmi-intc@01c00030 {
+   compatible = allwinner,sun7i-a20-sc-nmi;
+   interrupt-controller;
+   #interrupt-cells = 2;
+   reg = 0x01c00030 0x0c;
+   interrupt-parent = gic;
+   interrupts = 0 0 4;
+};
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[linux-sunxi] [PATCH v5 1/3] ARM: sun7i/sun6i: irqchip: Add irqchip driver for NMI controller

2014-03-05 Thread Carlo Caione
Allwinner A20/A31 SoCs have special registers to control / (un)mask /
acknowledge NMI. This NMI controller is separated and independent from GIC.
This patch adds a new irqchip to manage NMI.

Signed-off-by: Carlo Caione ca...@caione.org
Acked-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 drivers/irqchip/Makefile|   1 +
 drivers/irqchip/irq-sunxi-nmi.c | 228 
 2 files changed, 229 insertions(+)
 create mode 100644 drivers/irqchip/irq-sunxi-nmi.c

diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index c60b901..e31d4d6 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_METAG_PERFCOUNTER_IRQS)  += irq-metag.o
 obj-$(CONFIG_ARCH_MOXART)  += irq-moxart.o
 obj-$(CONFIG_ORION_IRQCHIP)+= irq-orion.o
 obj-$(CONFIG_ARCH_SUNXI)   += irq-sun4i.o
+obj-$(CONFIG_ARCH_SUNXI)   += irq-sunxi-nmi.o
 obj-$(CONFIG_ARCH_SPEAR3XX)+= spear-shirq.o
 obj-$(CONFIG_ARM_GIC)  += irq-gic.o
 obj-$(CONFIG_ARM_NVIC) += irq-nvic.o
diff --git a/drivers/irqchip/irq-sunxi-nmi.c b/drivers/irqchip/irq-sunxi-nmi.c
new file mode 100644
index 000..8796ae0
--- /dev/null
+++ b/drivers/irqchip/irq-sunxi-nmi.c
@@ -0,0 +1,228 @@
+/*
+ * Allwinner A20/A31 SoCs NMI IRQ chip driver.
+ *
+ * Carlo Caione carlo.cai...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/bitops.h
+#include linux/device.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/interrupt.h
+#include linux/irqdomain.h
+#include linux/of_irq.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/irqchip/chained_irq.h
+#include irqchip.h
+
+#define SUNXI_NMI_SRC_TYPE_MASK0x0003
+
+enum {
+   SUNXI_SRC_TYPE_LEVEL_LOW = 0,
+   SUNXI_SRC_TYPE_EDGE_FALLING,
+   SUNXI_SRC_TYPE_LEVEL_HIGH,
+   SUNXI_SRC_TYPE_EDGE_RISING,
+};
+
+struct sunxi_sc_nmi_reg_offs {
+   u32 ctrl;
+   u32 pend;
+   u32 enable;
+};
+
+static struct sunxi_sc_nmi_reg_offs sun7i_reg_offs = {
+   .ctrl   = 0x00,
+   .pend   = 0x04,
+   .enable = 0x08,
+};
+
+static struct sunxi_sc_nmi_reg_offs sun6i_reg_offs = {
+   .ctrl   = 0x00,
+   .pend   = 0x04,
+   .enable = 0x34,
+};
+
+/*
+ * Ack level interrupts right before unmask
+ *
+ * In case of level-triggered interrupt, IRQ line must be acked before it
+ * is unmasked or else a double-interrupt is triggered
+ */
+
+static void sunxi_sc_nmi_ack_and_unmask(struct irq_data *d)
+{
+   struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
+   struct irq_chip_type *ct = irq_data_get_chip_type(d);
+   u32 mask = d-mask;
+
+   if (irqd_get_trigger_type(d)  IRQ_TYPE_LEVEL_MASK)
+   ct-chip.irq_ack(d);
+
+   irq_gc_lock(gc);
+   irq_reg_writel(mask, gc-reg_base + ct-regs.mask);
+   irq_gc_unlock(gc);
+}
+
+static inline void sunxi_sc_nmi_write(struct irq_chip_generic *gc, u32 off,
+ u32 val)
+{
+   irq_reg_writel(val, gc-reg_base + off);
+}
+
+static inline u32 sunxi_sc_nmi_read(struct irq_chip_generic *gc, u32 off)
+{
+   return irq_reg_readl(gc-reg_base + off);
+}
+
+static void sunxi_sc_nmi_handle_irq(unsigned int irq, struct irq_desc *desc)
+{
+   struct irq_domain *domain = irq_desc_get_handler_data(desc);
+   struct irq_chip *chip = irq_get_chip(irq);
+   unsigned int virq = irq_find_mapping(domain, 0);
+
+   chained_irq_enter(chip, desc);
+   generic_handle_irq(virq);
+   chained_irq_exit(chip, desc);
+}
+
+static int sunxi_sc_nmi_set_type(struct irq_data *data, unsigned int flow_type)
+{
+   struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
+   struct irq_chip_type *ct = gc-chip_types;
+   u32 src_type_reg;
+   u32 ctrl_off = ct-regs.type;
+   unsigned int src_type;
+   unsigned int i;
+
+   irq_gc_lock(gc);
+
+   switch (flow_type  IRQF_TRIGGER_MASK) {
+   case IRQ_TYPE_EDGE_FALLING:
+   src_type = SUNXI_SRC_TYPE_EDGE_FALLING;
+   break;
+   case IRQ_TYPE_EDGE_RISING:
+   src_type = SUNXI_SRC_TYPE_EDGE_RISING;
+   break;
+   case IRQ_TYPE_LEVEL_HIGH:
+   src_type = SUNXI_SRC_TYPE_LEVEL_HIGH;
+   break;
+   case IRQ_TYPE_NONE:
+   case IRQ_TYPE_LEVEL_LOW:
+   src_type = SUNXI_SRC_TYPE_LEVEL_LOW;
+   break;
+   default:
+   irq_gc_unlock(gc);
+   pr_err(%s: Cannot assign multiple trigger modes to IRQ %d.\n,
+   __func__, data-irq);
+   return -EBADR;
+   }
+
+   irqd_set_trigger_type(data, flow_type);
+   irq_setup_alt_chip(data, flow_type

Re: [linux-sunxi] Re: [PATCH 0/7] mfd: AXP20x: Add support for AXP202 and AXP209

2014-03-05 Thread Carlo Caione
On Wed, Mar 5, 2014 at 9:02 PM, Hans de Goede hdego...@redhat.com wrote:

 So I've added your patches to my sunxi-devel tree and they work as advertised 
 :)

Thank you for keeping the tree updated :)

 I've also added dt support for the axp209 to the cubietruck dts file, to avoid
 things becoming a copy and paste fest I've introduced a new axp209.dtsi file,
 as well as did some fixes to the existing sun?i-a*.dtsi files, see my tree 
 here:
 https://github.com/jwrdegoede/linux-sunxi/commits/sunxi-devel

That was also my idea (creating a new axp20x.dtsi) but it has been
turned down by Maxime and Lee

 If you agree this is a good idea feel free to steal it all for the next
 revision of your patch-set :)

I will do for sure, thanks

 Note that I've still left some copy-paste parts inside the per board dts 
 files,
 specifically things which may differ per board, ie we know already that A10
 boards will have a different interrupt parent for the interrupt.

Yep, no prob.

 Thanks for your work on this!

Thank you!

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


  1   2   >