[PATCH 2/7] ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones.

2018-06-21 Thread Paweł Chmiel
This DTS file have initial support Samsung Aries based phones.
Initial version have support for:
- sdcard
- internal memory (present only on non 4g variant)
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Paweł Chmiel 
---
 arch/arm/boot/dts/s5pv210-aries.dtsi | 397 +++
 1 file changed, 397 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi

diff --git a/arch/arm/boot/dts/s5pv210-aries.dtsi 
b/arch/arm/boot/dts/s5pv210-aries.dtsi
new file mode 100644
index ..6e8ac3615765
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-aries.dtsi
@@ -0,0 +1,397 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Samsung's S5PV210 based Galaxy Aries board device tree source
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include 
+#include "s5pv210.dtsi"
+
+/ {
+   compatible = "samsung,aries", "samsung,s5pv210";
+
+   aliases {
+   i2c6 = &i2c_pmic;
+   i2c9 = &i2c_fuel;
+   };
+
+   memory@3000 {
+   device_type = "memory";
+   reg = <0x3000 0x0500
+   0x4000 0x1000
+   0x5000 0x0800>;
+   };
+
+   wifi_pwrseq: wifi-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpg1 2 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&wlan_gpio_rst>;
+   post-power-on-delay-ms = <500>;
+   power-off-delay-us = <500>;
+   };
+
+   i2c_pmic: i2c-pmic {
+   compatible = "i2c-gpio";
+   sda-gpios = <&gpj4 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+   scl-gpios = <&gpj4 3 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+   i2c-gpio,delay-us = <2>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   pmic@66 {
+   compatible = "maxim,max8998";
+   reg = <0x66>;
+   interrupt-parent = <&gph0>;
+   interrupts = <7 0>;
+
+   max8998,pmic-buck1-default-dvs-idx = <1>;
+   max8998,pmic-buck1-dvs-gpios = <&gph0 3 
GPIO_ACTIVE_HIGH>,
+   <&gph0 4 
GPIO_ACTIVE_HIGH>;
+   max8998,pmic-buck1-dvs-voltage = <1275000>, <120>,
+   <105>, <95>;
+
+   max8998,pmic-buck2-default-dvs-idx = <0>;
+   max8998,pmic-buck2-dvs-gpio = <&gph0 5 
GPIO_ACTIVE_HIGH>;
+   max8998,pmic-buck2-dvs-voltage = <110>, <100>;
+
+   regulators {
+   ldo2_reg: LDO2 {
+   regulator-name = "VALIVE_1.2V";
+   regulator-min-microvolt = <120>;
+   regulator-max-microvolt = <120>;
+   regulator-always-on;
+
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   };
+   };
+
+   ldo3_reg: LDO3 {
+   regulator-name = "VUSB_1.1V";
+   regulator-min-microvolt = <110>;
+   regulator-max-microvolt = <110>;
+
+   regulator-state-mem {
+   regulator-off-in-suspend;
+   };
+   };
+
+   ldo4_reg: LDO4 {
+   regulator-name = "VADC_3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+
+   regulator-state-mem {
+   regulator-off-in-suspend;
+   };
+   };
+
+   ldo5_reg: LDO5 {
+   regulator-name = "VTF_2.8V";
+   regulator-min-microvolt = <280

[PATCH 5/7] dt-bindings: samsung: Document bindings for Samsung aries boards

2018-06-21 Thread Paweł Chmiel
Signed-off-by: Paweł Chmiel 
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index 14510b215480..edce6602de50 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -2,6 +2,8 @@
 
 Required root node properties:
 - compatible = should be one or more of the following.
+   - "samsung,aries"   - for S5PV210-based Samsung Aries board.
+   - "samsung,galaxys" - for S5PV210-based Samsung Galaxy S (i9000)  
board.
- "samsung,artik5"  - for Exynos3250-based Samsung ARTIK5 module.
- "samsung,artik5-eval" - for Exynos3250-based Samsung ARTIK5 eval 
board.
- "samsung,monk"- for Exynos3250-based Samsung Simband board.
-- 
2.7.4



[PATCH 7/7] dt-bindings: samsung: Document binding for SGH-T959P board

2018-06-21 Thread Paweł Chmiel
From: Jonathan Bakker 

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index edce6602de50..8a9358336aab 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -3,6 +3,7 @@
 Required root node properties:
 - compatible = should be one or more of the following.
- "samsung,aries"   - for S5PV210-based Samsung Aries board.
+   - "samsung,fascinate4g" - for S5PV210-based Samsung Galaxy S Fascinate 
4G (SGH-T959P) board.
- "samsung,galaxys" - for S5PV210-based Samsung Galaxy S (i9000)  
board.
- "samsung,artik5"  - for Exynos3250-based Samsung ARTIK5 module.
- "samsung,artik5-eval" - for Exynos3250-based Samsung ARTIK5 eval 
board.
-- 
2.7.4



[PATCH 0/7] Initial support for Samsung Galaxy S and Galaxy S 4G

2018-06-21 Thread Paweł Chmiel
Jonathan Bakker (2):
  ARM: dts: s5pv210: Add initial DTS config for SGH-T959P phone
  dt-bindings: samsung: Document binding for SGH-T959P board

Paweł Chmiel (5):
  ARM: dts: s5pv210: Add missing interrupt-controller property to gph2
  ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones.
  ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone.
  ARM: s5pv210_defconfig: Enable drivers for Samsung Aries based phones
  dt-bindings: samsung: Document bindings for Samsung aries boards

 .../bindings/arm/samsung/samsung-boards.txt|   3 +
 arch/arm/boot/dts/Makefile |   2 +
 arch/arm/boot/dts/s5pv210-aries.dtsi   | 397 +
 arch/arm/boot/dts/s5pv210-fascinate4g.dts  |  40 +++
 arch/arm/boot/dts/s5pv210-galaxys.dts  |  72 
 arch/arm/boot/dts/s5pv210-pinctrl.dtsi |   2 +
 arch/arm/configs/s5pv210_defconfig |  49 ++-
 7 files changed, 562 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi
 create mode 100644 arch/arm/boot/dts/s5pv210-fascinate4g.dts
 create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts

-- 
2.7.4



[PATCH 6/7] ARM: dts: s5pv210: Add initial DTS config for SGH-T959P phone

2018-06-21 Thread Paweł Chmiel
From: Jonathan Bakker 

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/s5pv210-fascinate4g.dts | 40 +++
 2 files changed, 41 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-fascinate4g.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 522ebdca1d3d..d00e995875bb 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-smdk6410.dtb
 dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
+   s5pv210-fascinate4g.dtb \
s5pv210-galaxys.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
diff --git a/arch/arm/boot/dts/s5pv210-fascinate4g.dts 
b/arch/arm/boot/dts/s5pv210-fascinate4g.dts
new file mode 100644
index ..37967f57c7b7
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-fascinate4g.dts
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include 
+#include "s5pv210-aries.dtsi"
+
+/ {
+   model = "Samsung Galaxy S Fascinate 4G (SGH-T959P) based on S5PV210";
+   compatible = "samsung,fascinate4g", "samsung,aries", "samsung,s5pv210";
+
+   chosen {
+   bootargs = "console=ttySAC2,115200n8 root=/dev/mmcblk1p1 rw 
rootwait ignore_loglevel earlyprintk";
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   power {
+   label = "power";
+   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+
+   vol-down {
+   label = "volume_down";
+   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   vol-up {
+   label = "volume_up";
+   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+};
-- 
2.7.4



[PATCH 1/7] ARM: dts: s5pv210: Add missing interrupt-controller property to gph2

2018-06-21 Thread Paweł Chmiel
Adds missing interrupt-controller property to gph2 block,
to silence following warnings during build
  /soc/pinctrl@e020/gph2: Missing interrupt-controller or interrupt-map 
property

It's reguired by Samsung aries boards, an S5PV210 based
Samsung Galaxy S (i9000) and Galaxy S 4G phones, which are added in next 
patches.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/boot/dts/s5pv210-pinctrl.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/s5pv210-pinctrl.dtsi 
b/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
index 3a79feab11c3..7f0c9d447871 100644
--- a/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
+++ b/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
@@ -258,6 +258,8 @@
gph2: gph2 {
gpio-controller;
#gpio-cells = <2>;
+
+   interrupt-controller;
#interrupt-cells = <2>;
};
 
-- 
2.7.4



[PATCH 3/7] ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone.

2018-06-21 Thread Paweł Chmiel
Signed-off-by: Paweł Chmiel 
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/s5pv210-galaxys.dts | 72 +++
 2 files changed, 73 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 7e2424957809..522ebdca1d3d 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-smdk6410.dtb
 dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
+   s5pv210-galaxys.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
s5pv210-smdkv210.dtb \
diff --git a/arch/arm/boot/dts/s5pv210-galaxys.dts 
b/arch/arm/boot/dts/s5pv210-galaxys.dts
new file mode 100644
index ..d435032541a9
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-galaxys.dts
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include 
+#include "s5pv210-aries.dtsi"
+
+/ {
+   model = "Samsung Galaxy S1 (GT-I9000) based on S5PV210";
+   compatible = "samsung,galaxys", "samsung,aries", "samsung,s5pv210";
+
+   chosen {
+   bootargs = "console=ttySAC2,115200n8 root=/dev/mmcblk2p1 rw 
rootwait ignore_loglevel earlyprintk";
+   };
+
+   nand_pwrseq: nand-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpj2 7 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&massmemory_en>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   power {
+   label = "power";
+   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+
+   vol-down {
+   label = "volume_down";
+   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   vol-up {
+   label = "volume_up";
+   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   home {
+   label = "home";
+   gpios = <&gph3 5 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+   };
+};
+
+&pinctrl0 {
+   massmemory_en: massmemory-en {
+   samsung,pins = "gpj2-7";
+   samsung,pin-function = ;
+   samsung,pin-pud = ;
+   samsung,pin-drv = ;
+   };
+};
+
+&sdhci0 {
+   bus-width = <4>;
+   non-removable;
+   mmc-pwrseq = <&nand_pwrseq>;
+   pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4>;
+   pinctrl-names = "default";
+   status = "okay";
+};
-- 
2.7.4



[PATCH 4/7] ARM: s5pv210_defconfig: Enable drivers for Samsung Aries based phones

2018-06-21 Thread Paweł Chmiel
Enable config options required for Samsung Aries based phones..
While we're here, also enable other useful options like:
- SYSVIPC
- CGROUPS
- DEVTMPFS
- networking support
- ext4 and autofs

Signed-off-by: Paweł Chmiel 
---
 arch/arm/configs/s5pv210_defconfig | 49 +++---
 1 file changed, 46 insertions(+), 3 deletions(-)

diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index 09b5a7386414..a077597369f1 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -1,5 +1,7 @@
+CONFIG_SYSVIPC=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
+CONFIG_CGROUPS=y
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_SYSFS_DEPRECATED_V2=y
 CONFIG_BLK_DEV_INITRD=y
@@ -13,28 +15,68 @@ CONFIG_SOLARIS_X86_PARTITION=y
 CONFIG_ARCH_S5PV210=y
 CONFIG_VMSPLIT_2G=y
 CONFIG_PREEMPT=y
-CONFIG_AEABI=y
+CONFIG_ARM_APPENDED_DTB=y
 CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x2080,8M 
console=ttySAC1,115200 init=/linuxrc"
 CONFIG_VFP=y
 CONFIG_NEON=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_CFG80211=m
+CONFIG_MAC80211=m
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y
+CONFIG_NETDEVICES=y
+CONFIG_BRCMFMAC=m
 CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_KEYBOARD is not set
+CONFIG_KEYBOARD_GPIO=y
 # CONFIG_INPUT_MOUSE is not set
 CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_SAMSUNG=y
 CONFIG_SERIAL_SAMSUNG_CONSOLE=y
 CONFIG_HW_RANDOM=y
+CONFIG_I2C_GPIO=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_BATTERY_MAX17040=y
 # CONFIG_HWMON is not set
-# CONFIG_USB_SUPPORT is not set
+CONFIG_MFD_MAX8998=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_MAX8998=y
+CONFIG_DRM=y
+CONFIG_DRM_EXYNOS=y
+CONFIG_DRM_EXYNOS_FIMD=y
+CONFIG_DRM_EXYNOS_DPI=y
+CONFIG_USB=y
+CONFIG_USB_OTG=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_EXYNOS=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_EXYNOS=y
+CONFIG_USB_DWC2=y
+CONFIG_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_S3C=y
+CONFIG_MMC_SDHCI_S3C_DMA=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_MAX8998=m
+CONFIG_PHY_SAMSUNG_USB2=m
+CONFIG_PHY_S5PV210_USB2=y
 CONFIG_EXT2_FS=y
+CONFIG_EXT4_FS=y
+CONFIG_AUTOFS4_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
 CONFIG_TMPFS=y
@@ -44,6 +86,7 @@ CONFIG_ROMFS_FS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_UTF8=y
 CONFIG_DEBUG_INFO=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_KERNEL=y
-- 
2.7.4



Re: [PATCH 3/7] ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone.

2018-06-22 Thread Paweł Chmiel
On Friday, June 22, 2018 9:49:42 AM CEST Krzysztof Kozlowski wrote:
> On 21 June 2018 at 21:09, Paweł Chmiel  wrote:
> > Signed-off-by: Paweł Chmiel 
> 
> Please add commit message. This can be something as simple as "Add
> Samsung Galaxy S DTS which is a commercial phone based on Aries
> family." or something more (e.g. describe what is working).
> 
> > ---
> >  arch/arm/boot/dts/Makefile|  1 +
> >  arch/arm/boot/dts/s5pv210-galaxys.dts | 72 
> > +++
> >  2 files changed, 73 insertions(+)
> >  create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts
> >
> > diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> > index 7e2424957809..522ebdca1d3d 100644
> > --- a/arch/arm/boot/dts/Makefile
> > +++ b/arch/arm/boot/dts/Makefile
> > @@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
> > s3c6410-smdk6410.dtb
> >  dtb-$(CONFIG_ARCH_S5PV210) += \
> > s5pv210-aquila.dtb \
> > +   s5pv210-galaxys.dtb \
> > s5pv210-goni.dtb \
> > s5pv210-smdkc110.dtb \
> > s5pv210-smdkv210.dtb \
> > diff --git a/arch/arm/boot/dts/s5pv210-galaxys.dts 
> > b/arch/arm/boot/dts/s5pv210-galaxys.dts
> > new file mode 100644
> > index ..d435032541a9
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/s5pv210-galaxys.dts
> > @@ -0,0 +1,72 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +/dts-v1/;
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> 
> Duplicated inclusion.
> 
> > +#include "s5pv210-aries.dtsi"
> > +
> > +/ {
> > +   model = "Samsung Galaxy S1 (GT-I9000) based on S5PV210";
> > +   compatible = "samsung,galaxys", "samsung,aries", "samsung,s5pv210";
> > +
> > +   chosen {
> > +   bootargs = "console=ttySAC2,115200n8 root=/dev/mmcblk2p1 rw 
> > rootwait ignore_loglevel earlyprintk";
> 
> stdout-path = "serial2:115200n8";
> 
> Rest of bootargs should not be here (they are not HW dependent) unless
> you cannot configure them through bootloader?
> 
Stock (proprietary) bootloader is little problematic for me:
- to access it, You need to build special cable.
- i wasn't able to boot any kernel newer than 2.6.35/3.0 on it, without 
following hack/patch
https://github.com/tom3q/linux/commit/af96ebcba03b607ab93bd5778301890feb038479.patch

I would like to leave those bootargs for now, so anyone can easly test this 
kernel (just with that one patch),
without breaking booting existing software, so they could easly go back to 
stock software by just flashing old kernel.
Later it'll be removed because there is initial port of mainline u-boot started 
for both devices
- currently it can be flashed to device, instead of kernel and boot kernels 
from onenand/sdcard.
In this way migration from old kernel to new one will be much easier to users 
(and won't require special tools/cables/etc).


> > +   };
> > +
> > +   nand_pwrseq: nand-pwrseq {
> > +   compatible = "mmc-pwrseq-simple";
> > +   reset-gpios = <&gpj2 7 GPIO_ACTIVE_LOW>;
> > +   pinctrl-names = "default";
> > +   pinctrl-0 = <&massmemory_en>;
> 
> massmemory_en is used only here, so please move it from aries.dtsi.
> The same applies to all other possible properties if they are not used
> in other DTSes including aries.
> 
> > +   };
> > +
> > +   gpio-keys {
> > +   compatible = "gpio-keys";
> > +
> > +   power {
> > +   label = "power";
> > +   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
> > +   linux,code = ;
> > +   wakeup-source;
> > +   };
> > +
> > +   vol-down {
> > +   label = "volume_down";
> > +   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
> > +   linux,code = ;
> > +   };
> > +
> > +   vol-up {
> > +   label = "volume_up";
> > +   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
> > +   linux,code = ;
> > +   };
> > +
> > +   home {
> > +   label = "home";
> > +   gpios = <&gph3 5 GPIO_ACTIVE_LOW>;
> > +   linux,code = ;
> > +   wakeup-source;
> > +   };
> > +   };
> > +};
> > +
> > +&pinctrl0 {
> > +   massmemory_en: massmemory-en {
> 
> Oh wait, I see massmemory_en here... so there is no need of such in 
> aries.dtsi.
> 
> Best regards,
> Krzysztof
> 
> > +   samsung,pins = "gpj2-7";
> > +   samsung,pin-function = ;
> > +   samsung,pin-pud = ;
> > +   samsung,pin-drv = ;
> > +   };
> > +};
> > +
> > +&sdhci0 {
> > +   bus-width = <4>;
> > +   non-removable;
> > +   mmc-pwrseq = <&nand_pwrseq>;
> > +   pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4>;
> > +   pinctrl-names = "default";
> > +   status = "okay";
> > +};
> > --
> > 2.7.4
> >
> 




Re: [PATCH 2/7] ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones.

2018-06-22 Thread Paweł Chmiel
On Friday, June 22, 2018 9:41:02 AM CEST Krzysztof Kozlowski wrote:
> On 21 June 2018 at 21:09, Paweł Chmiel  wrote:
> > This DTS file have initial support Samsung Aries based phones.
> > Initial version have support for:
> > - sdcard
> > - internal memory (present only on non 4g variant)
> > - max8998 pmic and rtc
> > - max17040 fuel gauge
> > - gpio keys
> > - fimd (no panel driver yet)
> > - usb (peripherial mode)
> > - wifi
> >
> > Signed-off-by: Paweł Chmiel 
> 
> Hi Pawel,
> 
> Nice job in mainlining!
> 
> Below you'll find some comments for improvement.
Thanks for all comments. I'll prepare v2 version with all issues fixed.

> 
> > ---
> >  arch/arm/boot/dts/s5pv210-aries.dtsi | 397 
> > +++
> >  1 file changed, 397 insertions(+)
> >  create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi
> >
> > diff --git a/arch/arm/boot/dts/s5pv210-aries.dtsi 
> > b/arch/arm/boot/dts/s5pv210-aries.dtsi
> > new file mode 100644
> > index ..6e8ac3615765
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/s5pv210-aries.dtsi
> > @@ -0,0 +1,397 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Samsung's S5PV210 based Galaxy Aries board device tree source
> > + */
> > +
> > +/dts-v1/;
> > +#include 
> > +#include 
> > +#include 
> 
> Is the input header used here?
> 
> > +#include 
> 
> Duplicated inclusion.
> 
> > +#include "s5pv210.dtsi"
> > +
> > +/ {
> > +   compatible = "samsung,aries", "samsung,s5pv210";
> > +
> > +   aliases {
> > +   i2c6 = &i2c_pmic;
> > +   i2c9 = &i2c_fuel;
> > +   };
> > +
> > +   memory@3000 {
> > +   device_type = "memory";
> > +   reg = <0x3000 0x0500
> > +   0x4000 0x1000
> > +   0x5000 0x0800>;
> > +   };
> > +
> > +   wifi_pwrseq: wifi-pwrseq {
> > +   compatible = "mmc-pwrseq-simple";
> > +   reset-gpios = <&gpg1 2 GPIO_ACTIVE_LOW>;
> > +   pinctrl-names = "default";
> > +   pinctrl-0 = <&wlan_gpio_rst>;
> > +   post-power-on-delay-ms = <500>;
> > +   power-off-delay-us = <500>;
> > +   };
> > +
> > +   i2c_pmic: i2c-pmic {
> 
> s/i2c-pmic/ to /i2c-gpio-0/
> to reflect generic class of this node. Change only the node name. The
> label can stay as is.
> 
> > +   compatible = "i2c-gpio";
> > +   sda-gpios = <&gpj4 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
> > +   scl-gpios = <&gpj4 3 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
> 
> Spaces around pipe |.
> 
> > +   i2c-gpio,delay-us = <2>;
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +
> > +   pmic@66 {
> > +   compatible = "maxim,max8998";
> > +   reg = <0x66>;
> > +   interrupt-parent = <&gph0>;
> > +   interrupts = <7 0>;
> 
> If you really wanted 0 then IRQ_TYPE_NONE... but this should be a
> proper interrupt type.
> 
> > +
> > +   max8998,pmic-buck1-default-dvs-idx = <1>;
> > +   max8998,pmic-buck1-dvs-gpios = <&gph0 3 
> > GPIO_ACTIVE_HIGH>,
> > +   <&gph0 4 
> > GPIO_ACTIVE_HIGH>;
> > +   max8998,pmic-buck1-dvs-voltage = <1275000>, 
> > <120>,
> > +   <105>, <95>;
> > +
> > +   max8998,pmic-buck2-default-dvs-idx = <0>;
> > +   max8998,pmic-buck2-dvs-gpio = <&gph0 5 
> > GPIO_ACTIVE_HIGH>;
> > +   max8998,pmic-buck2-dvs-voltage = <110>, 
> > <100>;
> > +
> > +   regulators {
> > +   ldo2_reg: LDO2 {
> > +   regulator-name = "VALIVE_1.2V";
> > +   regulator-min-microvolt = <120>;
> > +

Re: [PATCH v2 1/2] Input: atmel_mxt_ts: Add support for optional regulators.

2018-07-28 Thread Paweł Chmiel
On Thursday, July 19, 2018 9:54:04 PM CEST Nick Dyer wrote:
> On Wed, Jul 18, 2018 at 06:21:30PM +0200, Paweł Chmiel wrote:
> > On Tuesday, July 17, 2018 10:00:05 PM CEST Nick Dyer wrote:
> > > On Tue, Jul 17, 2018 at 08:16:25PM +0200, Paweł Chmiel wrote:
> > > > This patch adds optional regulators, which can be used to power
> > > > up touchscreen. After enabling regulators, we need to wait 150msec.
> > > > This value is taken from official driver.
> > > > 
> > > > It was tested on Samsung Galaxy i9000 (based on Samsung S5PV210 SOC).
> > > > 
> > > > Signed-off-by: Paweł Chmiel 
> > > > ---
> > > > Changes from v1:
> > > >   - Enable regulators only if reset_gpio is present.
> > > >   - Switch from devm_regulator_get_optional to devm_regulator_get
> > > > ---
> > > >  drivers/input/touchscreen/atmel_mxt_ts.c | 46 
> > > > ++--
> > > >  1 file changed, 44 insertions(+), 2 deletions(-)
> > > 
> > > Hi Pawel-
> > > 
> > > I see you've borrowed some of the logic from the patch I wrote a while
> > > back (see https://github.com/ndyer/linux/commit/8e9687e41ed062 )
> > Actually, i was looking at 
> > https://github.com/atmel-maxtouch/linux/blob/maxtouch-v3.14/drivers/input/touchscreen/atmel_mxt_ts.c
> >  (and didn't saw Your patch till now).
> > Are You going to submit it? (it has more functionalities - for example
> > suspend mode read from device tree).
> 
> Getting that work upstream has stalled for a couple of years because I
> changed jobs. I have actually started recently to dust it off again, it
> was later on in my queue but if you have the time to work on it that is
> great.
> 
> > > The correct behaviour according to Atmel should be:
> > > 
> > > * Make RESET zero
> > > * Bring up regulators
> > > * Wait for a period to settle (150 msec)
> > > * Release RESET
> > > * Wait for 100 msec whilst device gets through bootloader
> > > * Wait for CHG line assert before reading info block
> > > 
> > > I can't see the first and last steps in your patch at present.
> > About first step - reset_gpio is readed by using
> > devm_gpiod_get_optional with GPIOD_OUT_LOW flag, so i think (but might
> > be wrong)  that we don't need to set this gpio value again to 0 before
> > enabling regulators,
> 
> I see what you mean - that is fair enough.
> 
> > since currently only place where reset_gpio is used is in driver probe
> > (in Your patch it is used in other cases/places - for example in
> > mxt_start/stop, when we enable regulators).
> > About missing wait after releasing reset, shouldn't this be separate
> > patch (since currently driver is not doing it)? I can prepare it and
> > send with other in next version.
> 
> According to the maxtouch documentation, it isn't ready for comms until
> the firmware asserts the CHG line. I've seen a bunch of devices that get
> by without an explicit wait because the board file does the power on,
> and by the time the driver gets to probe it's a few hundred ms later
> anyway, so it doesn't matter. But if we put it all in the driver, it
> will attempt to read the info block straight after the 100 msec delay
> without waiting for CHG, and I suspect we'll end up with occasional
> probe failures. It'll depend on the maxtouch device, though: they have a
> range of different power on timings.
> 
> Which platform are you doing this for? Is it a Chromebook?
No, it's Samsung Galaxy S (i9000) phone with S5PV210 Samsung Soc.
I'm preparing v3 version with separate patch adding this wait/delay.
> 
> > Thanks for feedback
> > > 
> > > The only downside with this approach is that there are a lot of
> > > delays during driver probe, but I believe the asynchronous probe stuff
> > > that's landed since I wrote the original patch should address that.
> > > 
> > > cheers
> > > 
> > > Nick
> > > 
> > > > }
> > > > @@ -3116,6 +3154,10 @@ static int mxt_remove(struct i2c_client *client)
> > > > struct mxt_data *data = i2c_get_clientdata(client);
> > > >  
> > > > disable_irq(data->irq);
> > > > +   if (data->reset_gpio) {
> > > > +   regulator_disable(data->avdd_reg);
> > > > +   regulator_disable(data->vdd_reg);
> > > > +   }
> > > > sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
> > > > mxt_free_input_device(data);
> > > > mxt_free_object_table(data);
> > > 
> > 
> > 
> 




[PATCH v3 3/3] Input: atmel_mxt_ts: Document optional voltage regulators

2018-07-31 Thread Paweł Chmiel
Document new optional voltage regulators, which can be used
to power down/up touchscreen.

Signed-off-by: Paweł Chmiel 
Reviewed-by: Rob Herring 
---
Changes from v1:
  - Added reviewed-by
---
 Documentation/devicetree/bindings/input/atmel,maxtouch.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt 
b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
index c88919480d37..17930ecadad3 100644
--- a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
+++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
@@ -31,6 +31,12 @@ Optional properties for main touchpad device:
 
 - reset-gpios: GPIO specifier for the touchscreen's reset pin (active low)
 
+- avdd-supply: Analog power supply. It powers up the analog channel block
+of the controller to detect the touches.
+
+- vdd-supply: Digital power supply. It powers up the digital block
+of the controller to enable i2c communication.
+
 Example:
 
touch@4b {
@@ -38,4 +44,6 @@ Example:
reg = <0x4b>;
interrupt-parent = <&gpio>;
interrupts = ;
+   avdd-supply = <&atsp_reg>;
+   vdd-supply = <&tsp_reg>;
};
-- 
2.7.4



[PATCH v3 0/3] Input: atmel_mxt_ts: Add support for optional regulators

2018-07-31 Thread Paweł Chmiel
This patch series adds optional regulator support to atmel_mxt_ts.
First patch adds regulators to driver.
Second patch ensures that device is ready for communication.
Third patch updates documentation.

Changes from v2:
  - Add reviewed-by to one patch
  - Move code for enabling regulators into separate method,
to make code more readable.
  - Add wait code, to ensure that device is ready for communication.

Changes from v1:
  - Enable regulators only if reset_gpio is present.
  - Switch from devm_regulator_get_optional to devm_regulator_get.

Paweł Chmiel (3):
  Input: atmel_mxt_ts: Add support for  optional regulators.
  Input: atmel_mxt_ts: Wait for device be ready for communication
  Input: atmel_mxt_ts: Document optional voltage regulators

 .../devicetree/bindings/input/atmel,maxtouch.txt   |  8 +++
 drivers/input/touchscreen/atmel_mxt_ts.c   | 76 --
 2 files changed, 78 insertions(+), 6 deletions(-)

-- 
2.7.4



[PATCH v3 2/3] Input: atmel_mxt_ts: Wait for device be ready for communication

2018-07-31 Thread Paweł Chmiel
According to documentation, device isn't ready for communication,
until firmware asserts the CHG line. Add missing wait for this.

Signed-off-by: Paweł Chmiel 
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index 2cd7f6db6ba9..79e08916359f 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -202,6 +202,7 @@ enum t100_type {
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
+#define MXT_POWERON_DELAY  150 /* msec */
 
 /* Command to unlock bootloader */
 #define MXT_UNLOCK_CMD_MSB 0xaa
@@ -3046,6 +3047,16 @@ static int mxt_regulator_enable(struct mxt_data *data)
msleep(MXT_REGULATOR_DELAY);
gpiod_set_value(data->reset_gpio, 1);
msleep(MXT_RESET_INVALID_CHG);
+
+retry_wait:
+   reinit_completion(&data->bl_completion);
+   data->in_bootloader = true;
+   error = mxt_wait_for_completion(data, &data->bl_completion,
+   
MXT_POWERON_DELAY);
+   if (error == -EINTR)
+   goto retry_wait;
+
+   data->in_bootloader = false;
}
 
return 0;
-- 
2.7.4



[PATCH v3 1/3] Input: atmel_mxt_ts: Add support for optional regulators.

2018-07-31 Thread Paweł Chmiel
This patch adds optional regulators, which can be used to power
up touchscreen. After enabling regulators, we need to wait 150msec.
This value is taken from official driver.

It was tested on Samsung Galaxy i9000 (based on Samsung S5PV210 SOC).

Signed-off-by: Paweł Chmiel 
---
Changes from v2:
  - Move code enabling regulators into separate method,
to make code more readable.

Changes from v1:
  - Enable regulators only if reset_gpio is present.
  - Switch from devm_regulator_get_optional to devm_regulator_get
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 65 +---
 1 file changed, 59 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index 54fe190fd4bc..2cd7f6db6ba9 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -194,10 +195,10 @@ enum t100_type {
 
 /* Delay times */
 #define MXT_BACKUP_TIME50  /* msec */
-#define MXT_RESET_GPIO_TIME20  /* msec */
 #define MXT_RESET_INVALID_CHG  100 /* msec */
 #define MXT_RESET_TIME 200 /* msec */
 #define MXT_RESET_TIMEOUT  3000/* msec */
+#define MXT_REGULATOR_DELAY150 /* msec */
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
@@ -310,6 +311,8 @@ struct mxt_data {
struct t7_config t7_cfg;
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
+   struct regulator *vdd_reg;
+   struct regulator *avdd_reg;
 
/* Cached parameters from object table */
u16 T5_address;
@@ -3016,6 +3019,38 @@ static const struct dmi_system_id 
chromebook_T9_suspend_dmi[] = {
{ }
 };
 
+static int mxt_regulator_enable(struct mxt_data *data)
+{
+   int error;
+
+   if (data->reset_gpio) {
+   error = regulator_enable(data->vdd_reg);
+   if (error) {
+   dev_err(&data->client->dev, "Failed to enable vdd 
regulator: %d\n",
+   error);
+   return error;
+   }
+
+   error = regulator_enable(data->avdd_reg);
+   if (error) {
+   dev_err(&data->client->dev, "Failed to enable avdd 
regulator: %d\n",
+   error);
+   return error;
+   }
+
+   /*
+* According to maXTouch power sequencing specification, RESET 
line
+* must be kept low until some time after regulators come up to
+* voltage
+*/
+   msleep(MXT_REGULATOR_DELAY);
+   gpiod_set_value(data->reset_gpio, 1);
+   msleep(MXT_RESET_INVALID_CHG);
+   }
+
+   return 0;
+}
+
 static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
struct mxt_data *data;
@@ -3076,6 +3111,22 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
return error;
}
 
+   data->vdd_reg = devm_regulator_get(&client->dev, "vdd");
+   if (IS_ERR(data->vdd_reg)) {
+   error = PTR_ERR(data->vdd_reg);
+   dev_err(&client->dev, "Failed to get vdd regulator: %d\n",
+   error);
+   return error;
+   }
+
+   data->avdd_reg = devm_regulator_get(&client->dev, "avdd");
+   if (IS_ERR(data->avdd_reg)) {
+   error = PTR_ERR(data->avdd_reg);
+   dev_err(&client->dev, "Failed to get avdd regulator: %d\n",
+   error);
+   return error;
+   }
+
error = devm_request_threaded_irq(&client->dev, client->irq,
  NULL, mxt_interrupt, IRQF_ONESHOT,
  client->name, data);
@@ -3086,11 +3137,9 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
 
disable_irq(client->irq);
 
-   if (data->reset_gpio) {
-   msleep(MXT_RESET_GPIO_TIME);
-   gpiod_set_value(data->reset_gpio, 1);
-   msleep(MXT_RESET_INVALID_CHG);
-   }
+   error = mxt_regulator_enable(data);
+   if (error)
+   return error;
 
error = mxt_initialize(data);
if (error)
@@ -3116,6 +3165,10 @@ static int mxt_remove(struct i2c_client *client)
struct mxt_data *data = i2c_get_clientdata(client);
 
disable_irq(data->irq);
+   if (data->reset_gpio) {
+   regulator_disable(data->avdd_reg);
+   regulator_

[PATCH 0/2] Input: atmel_mxt_ts: Add support for optional regulators

2018-07-13 Thread Paweł Chmiel
This two patches add optional regulator support to atmel_mxt_ts.
First patch adds regulators to driver.
Second patch updates documentation.

Paweł Chmiel (2):
  Input: atmel_mxt_ts: Add support for  optional regulators.
  Input: atmel_mxt_ts: Document optional voltage regulators

 .../devicetree/bindings/input/atmel,maxtouch.txt   |  8 
 drivers/input/touchscreen/atmel_mxt_ts.c   | 45 ++
 2 files changed, 53 insertions(+)

-- 
2.7.4



[PATCH 2/2] Input: atmel_mxt_ts: Document optional voltage regulators

2018-07-13 Thread Paweł Chmiel
Document new optional voltage regulators, which can be used
to power down/up touchscreen.

Signed-off-by: Paweł Chmiel 
---
 Documentation/devicetree/bindings/input/atmel,maxtouch.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt 
b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
index c88919480d37..17930ecadad3 100644
--- a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
+++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
@@ -31,6 +31,12 @@ Optional properties for main touchpad device:
 
 - reset-gpios: GPIO specifier for the touchscreen's reset pin (active low)
 
+- avdd-supply: Analog power supply. It powers up the analog channel block
+of the controller to detect the touches.
+
+- vdd-supply: Digital power supply. It powers up the digital block
+of the controller to enable i2c communication.
+
 Example:
 
touch@4b {
@@ -38,4 +44,6 @@ Example:
reg = <0x4b>;
interrupt-parent = <&gpio>;
interrupts = ;
+   avdd-supply = <&atsp_reg>;
+   vdd-supply = <&tsp_reg>;
};
-- 
2.7.4



[PATCH 1/2] Input: atmel_mxt_ts: Add support for optional regulators.

2018-07-13 Thread Paweł Chmiel
This patch adds optional regulators, which can be used to power
up touchscreen. After enabling regulators, we need to wait 150msec.
This value is taken from official driver.

It was tested on Samsung Galaxy i9000 (based on Samsung S5PV210 SOC).

Signed-off-by: Paweł Chmiel 
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 45 
 1 file changed, 45 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index 54fe190fd4bc..a7625ec8fb9f 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -198,6 +199,7 @@ enum t100_type {
 #define MXT_RESET_INVALID_CHG  100 /* msec */
 #define MXT_RESET_TIME 200 /* msec */
 #define MXT_RESET_TIMEOUT  3000/* msec */
+#define MXT_REGULATOR_DELAY150 /* msec */
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
@@ -310,6 +312,8 @@ struct mxt_data {
struct t7_config t7_cfg;
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
+   struct regulator *vdd_reg;
+   struct regulator *avdd_reg;
 
/* Cached parameters from object table */
u16 T5_address;
@@ -3076,6 +3080,40 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
return error;
}
 
+   data->vdd_reg = devm_regulator_get_optional(&client->dev, "vdd");
+   if (IS_ERR(data->vdd_reg)) {
+   error = PTR_ERR(data->vdd_reg);
+   dev_err(&client->dev, "Failed to get vdd regulator: %d\n",
+   error);
+   return error;
+   }
+
+   if (data->vdd_reg) {
+   error = regulator_enable(data->vdd_reg);
+   if (error) {
+   dev_err(&client->dev, "Failed to enable vdd regulator: 
%d\n",
+   error);
+   return error;
+   }
+   }
+
+   data->avdd_reg = devm_regulator_get_optional(&client->dev, "avdd");
+   if (IS_ERR(data->avdd_reg)) {
+   error = PTR_ERR(data->avdd_reg);
+   dev_err(&client->dev, "Failed to get avdd regulator: %d\n",
+   error);
+   return error;
+   }
+
+   if (data->avdd_reg) {
+   error = regulator_enable(data->avdd_reg);
+   if (error) {
+   dev_err(&client->dev, "Failed to enable avdd regulator: 
%d\n",
+   error);
+   return error;
+   }
+   }
+
error = devm_request_threaded_irq(&client->dev, client->irq,
  NULL, mxt_interrupt, IRQF_ONESHOT,
  client->name, data);
@@ -3086,6 +3124,9 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
 
disable_irq(client->irq);
 
+   if (!IS_ERR(data->vdd_reg) || !IS_ERR(data->avdd_reg))
+   msleep(MXT_REGULATOR_DELAY);
+
if (data->reset_gpio) {
msleep(MXT_RESET_GPIO_TIME);
gpiod_set_value(data->reset_gpio, 1);
@@ -3116,6 +3157,10 @@ static int mxt_remove(struct i2c_client *client)
struct mxt_data *data = i2c_get_clientdata(client);
 
disable_irq(data->irq);
+   if (!IS_ERR(data->avdd_reg))
+   regulator_disable(data->avdd_reg);
+   if (!IS_ERR(data->vdd_reg))
+   regulator_disable(data->vdd_reg);
sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
mxt_free_input_device(data);
mxt_free_object_table(data);
-- 
2.7.4



[PATCH v2 0/3] power: supply: max8998-charger:

2018-07-14 Thread Paweł Chmiel
This patch series compose of 3 patches.

First patch, fixes platform data retrieval issue in max8998 charger
driver, which could cause NULL pointer dereference.

Second patch, updates max8998 charger driver, so it's possible to parse
devicetree for configuration.

Third patch, updates max8998 documentation, so it includes new node 
and properties, needed for charger.

All patches has been tested on, Samsung Galaxy S (i9000) phone.

Changes from v1:
  - Removed unneeded Fixes tag
  - Correct description of all charger values
  - Added missing property unit for charger properties
  - Removed already applied patch

Paweł Chmiel (2):
  power: supply: max8998-charger: Parse device tree for required data.
  dt-bindings: mfd: max8998: Add charger subnode binding

Tomasz Figa (1):
  power: supply: max8998-charger: Fix platform data retrieval

 Documentation/devicetree/bindings/mfd/max8998.txt | 24 +++
 drivers/power/supply/max8998_charger.c| 52 ++-
 2 files changed, 75 insertions(+), 1 deletion(-)

-- 
2.7.4



[PATCH v2 1/3] power: supply: max8998-charger: Fix platform data retrieval

2018-07-14 Thread Paweł Chmiel
From: Tomasz Figa 

Since the max8998 MFD driver supports instantiation by DT, platform data
retrieval is handled in MFD probe and cell drivers should get use
the pdata field of max8998_dev struct to obtain them.

Fixes: ee999fb3f17f ("mfd: max8998: Add support for Device Tree")
Signed-off-by: Tomasz Figa 
Signed-off-by: Paweł Chmiel 
---
 drivers/power/supply/max8998_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/max8998_charger.c 
b/drivers/power/supply/max8998_charger.c
index b64cf0f14142..66438029bdd0 100644
--- a/drivers/power/supply/max8998_charger.c
+++ b/drivers/power/supply/max8998_charger.c
@@ -85,7 +85,7 @@ static const struct power_supply_desc max8998_battery_desc = {
 static int max8998_battery_probe(struct platform_device *pdev)
 {
struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent);
-   struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev);
+   struct max8998_platform_data *pdata = iodev->pdata;
struct power_supply_config psy_cfg = {};
struct max8998_battery_data *max8998;
struct i2c_client *i2c;
-- 
2.7.4



[PATCH v2 2/3] power: supply: max8998-charger: Parse device tree for required data.

2018-07-14 Thread Paweł Chmiel
This patch adds missing code for reading charger configuration
from devicetree.

Signed-off-by: Paweł Chmiel 
---
Changes from v1:
  - Removed unneeded Fixes tag
  - Use new property names
---
 drivers/power/supply/max8998_charger.c | 50 ++
 1 file changed, 50 insertions(+)

diff --git a/drivers/power/supply/max8998_charger.c 
b/drivers/power/supply/max8998_charger.c
index 66438029bdd0..0a03d3e05c3b 100644
--- a/drivers/power/supply/max8998_charger.c
+++ b/drivers/power/supply/max8998_charger.c
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -82,6 +83,49 @@ static const struct power_supply_desc max8998_battery_desc = 
{
.num_properties = ARRAY_SIZE(max8998_battery_props),
 };
 
+static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev,
+   struct max8998_platform_data *pdata)
+{
+   struct device_node *pmic_np = iodev->dev->of_node;
+   struct device_node *charger_np;
+   int ret;
+
+   charger_np = of_get_child_by_name(pmic_np, "charger");
+   if (!charger_np) {
+   dev_err(iodev->dev, "could not find charger sub-node\n");
+   return -EINVAL;
+   }
+
+   ret = of_property_read_u32(charger_np,
+   "max8998,charge-eoc-percent",
+   &pdata->eoc);
+   if (ret < 0) {
+   dev_err(iodev->dev,
+   "Could not find max8998,charge-eoc-percent in 
devicetree\n");
+   return ret;
+   }
+
+   ret = of_property_read_u32(charger_np,
+   
"max8998,charge-restart-level-microvolt",
+   &pdata->restart);
+   if (ret < 0) {
+   dev_err(iodev->dev,
+   "Could not find max8998,charge-restart-level-microvolt 
in devicetree\n");
+   return ret;
+   }
+
+   ret = of_property_read_u32(charger_np,
+   "max8998,charge-timeout-hours",
+   &pdata->timeout);
+   if (ret < 0) {
+   dev_err(iodev->dev,
+   "Could not find max8998,charge-timeout-hours in 
devicetree\n");
+   return ret;
+   }
+
+   return 0;
+}
+
 static int max8998_battery_probe(struct platform_device *pdev)
 {
struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent);
@@ -96,6 +140,12 @@ static int max8998_battery_probe(struct platform_device 
*pdev)
return -ENODEV;
}
 
+   if (IS_ENABLED(CONFIG_OF) && iodev->dev->of_node) {
+   ret = max8998_pmic_dt_parse_pdata(iodev, pdata);
+   if (ret)
+   return ret;
+   }
+
max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_battery_data),
GFP_KERNEL);
if (!max8998)
-- 
2.7.4



[PATCH v2 3/3] dt-bindings: mfd: max8998: Add charger subnode binding

2018-07-14 Thread Paweł Chmiel
This patch adds devicetree bindings documentation for
battery charging controller as the subnode of MAX8998 PMIC.

Signed-off-by: Paweł Chmiel 
---
Changes from v1:
  - Removed unneeded Fixes tag
  - Correct description of all charger values
  - Added missing property unit
---
 Documentation/devicetree/bindings/mfd/max8998.txt | 24 +++
 1 file changed, 24 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/max8998.txt 
b/Documentation/devicetree/bindings/mfd/max8998.txt
index 23a3650ff2a2..196e50097a36 100644
--- a/Documentation/devicetree/bindings/mfd/max8998.txt
+++ b/Documentation/devicetree/bindings/mfd/max8998.txt
@@ -50,6 +50,23 @@ Additional properties required if 
max8998,pmic-buck2-dvs-gpio is defined:
 - max8998,pmic-buck2-dvs-voltage: An array of 2 voltage values in microvolts
   for buck2 regulator that can be selected using dvs gpio.
 
+Charger: Configuration for battery charging controller should be added
+inside a child node named 'charger'.
+  Required properties:
+  - max8998,charge-eoc-percent: Setup End of Charge Level.
+If value equals 0, leave it unchanged.
+Otherwise it should be value from 10 to 45 by 5 step.
+
+  - max8998,charge-restart-level-microvolt: Setup Charge Restart Level.
+If value equals 0, leave it unchanged.
+If value equals -1, it will be disabled.
+Otherwise it should be one of following values: 100, 150, 200.
+
+  - max8998,charge-timeout-hours: Setup Charge Full Timeout.
+If value equals 0, leave it unchanged.
+If value equals -1, it will be disabled.
+Otherwise it should be one of following values: 5, 6, 7.
+
 Regulators: All the regulators of MAX8998 to be instantiated shall be
 listed in a child node named 'regulators'. Each regulator is represented
 by a child node of the 'regulators' node.
@@ -99,6 +116,13 @@ Example:
max8998,pmic-buck2-dvs-gpio = <&gpx0 0 3 0 0>; /* SET3 */
max8998,pmic-buck2-dvs-voltage = <135>, <130>;
 
+   /* Charger configuration */
+   charger {
+   max8998,charge-eoc-percent = <0>;
+   max8998,charge-restart-level-microvolt = <(-1)>;
+   max8998,charge-timeout-hours = <7>;
+   };
+
/* Regulators to instantiate */
regulators {
ldo2_reg: LDO2 {
-- 
2.7.4



[PATCH] pinctrl/samsung: Correct EINTG banks order

2018-04-08 Thread Paweł Chmiel
All banks with GPIO interrupts should be at beginning
of bank array and without any other types of banks between them.
This order is expected by exynos_eint_gpio_irq, when doing
interrupt group to bank translation.
Otherwise, kernel NULL pointer dereference would happen
when trying to handle interrupt, due to wrong bank being looked up.
Observed on s5pv210, when trying to handle gpj0 interrupt,
where kernel was mapping it to gpi bank.

Signed-off-by: Paweł Chmiel 
---
 drivers/pinctrl/samsung/pinctrl-exynos-arm.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c 
b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
index 90c2744..de4ab07 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
@@ -105,12 +105,12 @@ static const struct samsung_pin_bank_data 
s5pv210_pin_bank[] __initconst = {
EXYNOS_PIN_BANK_EINTG(7, 0x1c0, "gpg1", 0x38),
EXYNOS_PIN_BANK_EINTG(7, 0x1e0, "gpg2", 0x3c),
EXYNOS_PIN_BANK_EINTG(7, 0x200, "gpg3", 0x40),
-   EXYNOS_PIN_BANK_EINTN(7, 0x220, "gpi"),
EXYNOS_PIN_BANK_EINTG(8, 0x240, "gpj0", 0x44),
EXYNOS_PIN_BANK_EINTG(6, 0x260, "gpj1", 0x48),
EXYNOS_PIN_BANK_EINTG(8, 0x280, "gpj2", 0x4c),
EXYNOS_PIN_BANK_EINTG(8, 0x2a0, "gpj3", 0x50),
EXYNOS_PIN_BANK_EINTG(5, 0x2c0, "gpj4", 0x54),
+   EXYNOS_PIN_BANK_EINTN(7, 0x220, "gpi"),
EXYNOS_PIN_BANK_EINTN(8, 0x2e0, "mp01"),
EXYNOS_PIN_BANK_EINTN(4, 0x300, "mp02"),
EXYNOS_PIN_BANK_EINTN(8, 0x320, "mp03"),
@@ -158,9 +158,6 @@ static const struct samsung_pin_bank_data 
exynos3250_pin_banks0[] __initconst =
 
 /* pin banks of exynos3250 pin-controller 1 */
 static const struct samsung_pin_bank_data exynos3250_pin_banks1[] __initconst 
= {
-   EXYNOS_PIN_BANK_EINTN(8, 0x120, "gpe0"),
-   EXYNOS_PIN_BANK_EINTN(8, 0x140, "gpe1"),
-   EXYNOS_PIN_BANK_EINTN(3, 0x180, "gpe2"),
EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpk0", 0x08),
EXYNOS_PIN_BANK_EINTG(7, 0x060, "gpk1", 0x0c),
EXYNOS_PIN_BANK_EINTG(7, 0x080, "gpk2", 0x10),
@@ -170,6 +167,9 @@ static const struct samsung_pin_bank_data 
exynos3250_pin_banks1[] __initconst =
EXYNOS_PIN_BANK_EINTG(5, 0x2a0, "gpm2", 0x2c),
EXYNOS_PIN_BANK_EINTG(8, 0x2c0, "gpm3", 0x30),
EXYNOS_PIN_BANK_EINTG(8, 0x2e0, "gpm4", 0x34),
+   EXYNOS_PIN_BANK_EINTN(8, 0x120, "gpe0"),
+   EXYNOS_PIN_BANK_EINTN(8, 0x140, "gpe1"),
+   EXYNOS_PIN_BANK_EINTN(3, 0x180, "gpe2"),
EXYNOS_PIN_BANK_EINTW(8, 0xc00, "gpx0", 0x00),
EXYNOS_PIN_BANK_EINTW(8, 0xc20, "gpx1", 0x04),
EXYNOS_PIN_BANK_EINTW(8, 0xc40, "gpx2", 0x08),
@@ -630,7 +630,6 @@ static const struct samsung_pin_bank_data 
exynos5410_pin_banks0[] __initconst =
EXYNOS_PIN_BANK_EINTG(4, 0x100, "gpc3", 0x20),
EXYNOS_PIN_BANK_EINTG(7, 0x120, "gpc1", 0x24),
EXYNOS_PIN_BANK_EINTG(7, 0x140, "gpc2", 0x28),
-   EXYNOS_PIN_BANK_EINTN(2, 0x160, "gpm5"),
EXYNOS_PIN_BANK_EINTG(8, 0x180, "gpd1", 0x2c),
EXYNOS_PIN_BANK_EINTG(8, 0x1A0, "gpe0", 0x30),
EXYNOS_PIN_BANK_EINTG(2, 0x1C0, "gpe1", 0x34),
@@ -641,6 +640,7 @@ static const struct samsung_pin_bank_data 
exynos5410_pin_banks0[] __initconst =
EXYNOS_PIN_BANK_EINTG(2, 0x260, "gpg2", 0x48),
EXYNOS_PIN_BANK_EINTG(4, 0x280, "gph0", 0x4c),
EXYNOS_PIN_BANK_EINTG(8, 0x2A0, "gph1", 0x50),
+   EXYNOS_PIN_BANK_EINTN(2, 0x160, "gpm5"),
EXYNOS_PIN_BANK_EINTN(8, 0x2C0, "gpm7"),
EXYNOS_PIN_BANK_EINTN(6, 0x2E0, "gpy0"),
EXYNOS_PIN_BANK_EINTN(4, 0x300, "gpy1"),
-- 
2.7.4



[PATCH] Bluetooth: hci_bcm: Handle specific unknown packets after firmware loading

2018-12-05 Thread Paweł Chmiel
From: Jonathan Bakker 

The Broadcom controller on aries S5PV210 boards sends out a couple of
unknown packets after the firmware is loaded.  This will cause
logging of errors such as:
Bluetooth: hci0: Frame reassembly failed (-84)

This is probably also the case with other boards, as there are related
Android userspace patches for custom ROMs such as
https://review.lineageos.org/#/c/LineageOS/android_system_bt/+/142721/
Since this appears to be intended behaviour, treated them as diagnostic
packets.

Note that this is another variant of commit 01d5e44ace8a 
("Bluetooth: hci_bcm: Handle empty packet after firmware loading")

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 drivers/bluetooth/hci_bcm.c | 32 +++-
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index ddbd8c6a0ceb..ae271836dc26 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -51,6 +51,12 @@
 #define BCM_LM_DIAG_PKT 0x07
 #define BCM_LM_DIAG_SIZE 63
 
+#define BCM_UNKNOWN_PKT 0x31
+#define BCM_UNKNOWN_SIZE 0
+
+#define BCM_UNKNOWN2_PKT 0x34
+#define BCM_UNKNOWN2_SIZE 0
+
 #define BCM_AUTOSUSPEND_DELAY  5000 /* default autosleep delay */
 
 /**
@@ -561,12 +567,28 @@ static int bcm_setup(struct hci_uart *hu)
.lsize = 0, \
.maxlen = BCM_NULL_SIZE
 
+#define BCM_RECV_UNKNOWN \
+   .type = BCM_UNKNOWN_PKT, \
+   .hlen = BCM_UNKNOWN_SIZE, \
+   .loff = 0, \
+   .lsize = 0, \
+   .maxlen = BCM_UNKNOWN_SIZE
+
+#define BCM_RECV_UNKNOWN2 \
+   .type = BCM_UNKNOWN2_PKT, \
+   .hlen = BCM_UNKNOWN2_SIZE, \
+   .loff = 0, \
+   .lsize = 0, \
+   .maxlen = BCM_UNKNOWN2_SIZE
+
 static const struct h4_recv_pkt bcm_recv_pkts[] = {
-   { H4_RECV_ACL,  .recv = hci_recv_frame },
-   { H4_RECV_SCO,  .recv = hci_recv_frame },
-   { H4_RECV_EVENT,.recv = hci_recv_frame },
-   { BCM_RECV_LM_DIAG, .recv = hci_recv_diag  },
-   { BCM_RECV_NULL,.recv = hci_recv_diag  },
+   { H4_RECV_ACL,   .recv = hci_recv_frame },
+   { H4_RECV_SCO,   .recv = hci_recv_frame },
+   { H4_RECV_EVENT, .recv = hci_recv_frame },
+   { BCM_RECV_LM_DIAG,  .recv = hci_recv_diag  },
+   { BCM_RECV_NULL, .recv = hci_recv_diag  },
+   { BCM_RECV_UNKNOWN,  .recv = hci_recv_diag  },
+   { BCM_RECV_UNKNOWN2, .recv = hci_recv_diag  },
 };
 
 static int bcm_recv(struct hci_uart *hu, const void *data, int count)
-- 
2.17.1



[PATCH] Bluetooth: btbcm: Add entry for BCM4329B1 UART bluetooth

2018-12-05 Thread Paweł Chmiel
This patch adds the device ID for the BCM 4329 combo module used
in the Samsung Aries based phones (Galaxy S and it's variants).

```
[   11.508980] Bluetooth: hci0: BCM: chip id 41
[   11.518975] Bluetooth: hci0: BCM: features 0x04
[   11.550132] Bluetooth: hci0: BCM4329B1
[   11.557046] Bluetooth: hci0: BCM4329B1 (002.002.023) build 
[   13.737071] Bluetooth: hci0: BCM4329B1 (002.002.023) build 0744
```

Output from hciconfig

```
hci0:   Type: Primary  Bus: UART
BD Address: 43:29:B1:55:00:00  ACL MTU: 1021:6  SCO MTU: 64:1
UP RUNNING
RX bytes:1675 acl:0 sco:0 events:145 errors:0
TX bytes:20426 acl:0 sco:0 commands:146 errors:0
Features: 0xbf 0xfe 0x8f 0xfe 0x9b 0xff 0x79 0x83
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: 'aries'
Class: 0x00
Service Classes: Unspecified
Device Class: Miscellaneous,
HCI Version: 2.1 (0x4)  Revision: 0x2e8
LMP Version: 2.1 (0x4)  Subversion: 0x4217
Manufacturer: Broadcom Corporation (15)
```

Signed-off-by: Paweł Chmiel 
---
 drivers/bluetooth/btbcm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e3e4d929e74f..ba330096d2c6 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -330,6 +330,7 @@ static const struct bcm_subver_table 
bcm_uart_subver_table[] = {
{ 0x2209, "BCM43430A1"  },  /* 001.002.009 */
{ 0x6119, "BCM4345C0"   },  /* 003.001.025 */
{ 0x230f, "BCM4356A2"   },  /* 001.003.015 */
+   { 0x4217, "BCM4329B1"   },  /* 002.002.023 */
{ }
 };
 
-- 
2.17.1



[PATCH v2] Bluetooth: hci_bcm: Handle specific unknown packets after firmware loading

2018-12-05 Thread Paweł Chmiel
From: Jonathan Bakker 

The Broadcom controller on aries S5PV210 boards sends out a couple of
unknown packets after the firmware is loaded.  This will cause
logging of errors such as:
Bluetooth: hci0: Frame reassembly failed (-84)

This is probably also the case with other boards, as there are related
Android userspace patches for custom ROMs such as
https://review.lineageos.org/#/c/LineageOS/android_system_bt/+/142721/
Since this appears to be intended behaviour, treated them as diagnostic
packets.

Note that this is another variant of commit 01d5e44ace8a
("Bluetooth: hci_bcm: Handle empty packet after firmware loading")

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 

---
Changes from v1:
- Rename UNKNOWN to TYPE49
- Rename UNKNOWN2 to TYPE52
---
 drivers/bluetooth/hci_bcm.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index ddbd8c6a0ceb..7e7a2cfb2f93 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -51,6 +51,12 @@
 #define BCM_LM_DIAG_PKT 0x07
 #define BCM_LM_DIAG_SIZE 63
 
+#define BCM_TYPE49_PKT 0x31
+#define BCM_TYPE49_SIZE 0
+
+#define BCM_TYPE52_PKT 0x34
+#define BCM_TYPE52_SIZE 0
+
 #define BCM_AUTOSUSPEND_DELAY  5000 /* default autosleep delay */
 
 /**
@@ -561,12 +567,28 @@ static int bcm_setup(struct hci_uart *hu)
.lsize = 0, \
.maxlen = BCM_NULL_SIZE
 
+#define BCM_RECV_TYPE49 \
+   .type = BCM_TYPE49_PKT, \
+   .hlen = BCM_TYPE49_SIZE, \
+   .loff = 0, \
+   .lsize = 0, \
+   .maxlen = BCM_TYPE49_SIZE
+
+#define BCM_RECV_TYPE52 \
+   .type = BCM_TYPE52_PKT, \
+   .hlen = BCM_TYPE52_SIZE, \
+   .loff = 0, \
+   .lsize = 0, \
+   .maxlen = BCM_TYPE52_SIZE
+
 static const struct h4_recv_pkt bcm_recv_pkts[] = {
{ H4_RECV_ACL,  .recv = hci_recv_frame },
{ H4_RECV_SCO,  .recv = hci_recv_frame },
{ H4_RECV_EVENT,.recv = hci_recv_frame },
{ BCM_RECV_LM_DIAG, .recv = hci_recv_diag  },
{ BCM_RECV_NULL,.recv = hci_recv_diag  },
+   { BCM_RECV_TYPE49,  .recv = hci_recv_diag  },
+   { BCM_RECV_TYPE52,  .recv = hci_recv_diag  },
 };
 
 static int bcm_recv(struct hci_uart *hu, const void *data, int count)
-- 
2.17.1



Re: [PATCH] Bluetooth: hci_bcm: Handle specific unknown packets after firmware loading

2018-12-05 Thread Paweł Chmiel
Dnia środa, 5 grudnia 2018 22:02:30 CET Marcel Holtmann pisze:
> Hi Pawel,
> 
> > The Broadcom controller on aries S5PV210 boards sends out a couple of
> > unknown packets after the firmware is loaded.  This will cause
> > logging of errors such as:
> > Bluetooth: hci0: Frame reassembly failed (-84)
> > 
> > This is probably also the case with other boards, as there are related
> > Android userspace patches for custom ROMs such as
> > https://review.lineageos.org/#/c/LineageOS/android_system_bt/+/142721/
> > Since this appears to be intended behaviour, treated them as diagnostic
> > packets.
> > 
> > Note that this is another variant of commit 01d5e44ace8a 
> > ("Bluetooth: hci_bcm: Handle empty packet after firmware loading")
> > 
> > Signed-off-by: Jonathan Bakker 
> > Signed-off-by: Paweł Chmiel 
> > ---
> > drivers/bluetooth/hci_bcm.c | 32 +++-
> > 1 file changed, 27 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
> > index ddbd8c6a0ceb..ae271836dc26 100644
> > --- a/drivers/bluetooth/hci_bcm.c
> > +++ b/drivers/bluetooth/hci_bcm.c
> > @@ -51,6 +51,12 @@
> > #define BCM_LM_DIAG_PKT 0x07
> > #define BCM_LM_DIAG_SIZE 63
> > 
> > +#define BCM_UNKNOWN_PKT 0x31
> > +#define BCM_UNKNOWN_SIZE 0
> > +
> > +#define BCM_UNKNOWN2_PKT 0x34
> > +#define BCM_UNKNOWN2_SIZE 0
> > +
> 
> lets use BCM_TYPE49_ and BCM_TYPE52_
> 
> > #define BCM_AUTOSUSPEND_DELAY   5000 /* default autosleep delay */
> > 
> > /**
> > @@ -561,12 +567,28 @@ static int bcm_setup(struct hci_uart *hu)
> > .lsize = 0, \
> > .maxlen = BCM_NULL_SIZE
> > 
> > +#define BCM_RECV_UNKNOWN \
> > +   .type = BCM_UNKNOWN_PKT, \
> > +   .hlen = BCM_UNKNOWN_SIZE, \
> > +   .loff = 0, \
> > +   .lsize = 0, \
> > +   .maxlen = BCM_UNKNOWN_SIZE
> > +
> > +#define BCM_RECV_UNKNOWN2 \
> > +   .type = BCM_UNKNOWN2_PKT, \
> > +   .hlen = BCM_UNKNOWN2_SIZE, \
> > +   .loff = 0, \
> > +   .lsize = 0, \
> > +   .maxlen = BCM_UNKNOWN2_SIZE
> 
> Same here, BCM_RECV_TYPE49 and BCM_RECV_TYPE52.
> 
> > +
> > static const struct h4_recv_pkt bcm_recv_pkts[] = {
> > -   { H4_RECV_ACL,  .recv = hci_recv_frame },
> > -   { H4_RECV_SCO,  .recv = hci_recv_frame },
> > -   { H4_RECV_EVENT,.recv = hci_recv_frame },
> > -   { BCM_RECV_LM_DIAG, .recv = hci_recv_diag  },
> > -   { BCM_RECV_NULL,.recv = hci_recv_diag  },
> > +   { H4_RECV_ACL,   .recv = hci_recv_frame },
> > +   { H4_RECV_SCO,   .recv = hci_recv_frame },
> > +   { H4_RECV_EVENT, .recv = hci_recv_frame },
> > +   { BCM_RECV_LM_DIAG,  .recv = hci_recv_diag  },
> > +   { BCM_RECV_NULL, .recv = hci_recv_diag  },
> > +   { BCM_RECV_UNKNOWN,  .recv = hci_recv_diag  },
> > +   { BCM_RECV_UNKNOWN2, .recv = hci_recv_diag  },
> > };
> > 
> > static int bcm_recv(struct hci_uart *hu, const void *data, int count)
> 
> Regards
> 
> Marcel
> 
Hi
Fixed in v2 version of patch.

Thanks for review.





[PATCH 6/8] Input: dt-bindings: tm2-touchkey: Document new keycodes property

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Document new optional property for setting custom keycodes.

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 .../devicetree/bindings/input/cypress,tm2-touchkey.txt| 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt 
b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index dfb3b9f0ee40..3b54d997b8de 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -10,6 +10,9 @@ Required properties:
 - vcc-supply : internal regulator output. 1.8V
 - vdd-supply : power supply for IC 3.3V
 
+Optional properties:
+- keycodes: array of keycodes (max 4), default KEY_PHONE and KEY_BACK
+
 [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
 
 Example:
@@ -23,5 +26,6 @@ Example:
interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
vcc-supply=<&ldo32_reg>;
vdd-supply=<&ldo33_reg>;
+   keycodes = /bits/ 8 ;
};
};
-- 
2.17.1



[PATCH 3/8] Input: tm2-touchkey: Use predefined device name

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Purely a cosmetic fix, using the names defined earlier

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 drivers/input/keyboard/tm2-touchkey.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index 37a5ced24009..cc713b901bf2 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -57,13 +57,13 @@ struct tm2_touchkey_data {
 };
 
 static struct touchkey_variant tm2_touchkey_variant = {
-   .name = "tm2-touchkey",
+   .name = TM2_TOUCHKEY_DEV_NAME,
.keycode_reg = 0x03,
.base_reg = 0x00,
 };
 
 static struct touchkey_variant midas_touchkey_variant = {
-   .name = "midas-touchkey",
+   .name = MIDAS_TOUCHKEY_DEV_NAME,
.keycode_reg = 0x00,
.base_reg = 0x00,
 };
-- 
2.17.1



[PATCH 4/8] Input: tm2-touchkey: Correct initial brightness

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Tm2-touchkey don't have brightness levels, but only on/off states,
so replace LED_FULL with LED_ON.

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 drivers/input/keyboard/tm2-touchkey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index cc713b901bf2..a73894b8dede 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -235,7 +235,7 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 
/* led device */
touchkey->led_dev.name = touchkey->variant->name;
-   touchkey->led_dev.brightness = LED_FULL;
+   touchkey->led_dev.brightness = LED_ON;
touchkey->led_dev.max_brightness = LED_ON;
touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set;
 
-- 
2.17.1



[PATCH 8/8] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Document compatible for aries touchkey.

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt 
b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index 3b54d997b8de..c518125d16f5 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -4,6 +4,7 @@ Required properties:
 - compatible:
 * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
 * "cypress,midas-touchkey" - for the touchkey found on midas boards
+* "cypress,aries-touchkey" - for the touchkey found on aries boards
 - reg: I2C address of the chip.
 - interrupts: interrupt to which the chip is connected (see interrupt
binding[0]).
-- 
2.17.1



[PATCH 7/8] Input: tm2-touchkey: Add support for aries touchkey variant

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

The touchkey variant found on aries board is slighty different,
it uses a fixed regulator and writes/read to the same place

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 drivers/input/keyboard/tm2-touchkey.c | 56 +++
 1 file changed, 49 insertions(+), 7 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index ebc275ab8ad1..6f1235183c21 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -28,7 +28,10 @@
 
 #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey"
 #define MIDAS_TOUCHKEY_DEV_NAME "midas-touchkey"
+#define ARIES_TOUCHKEY_DEV_NAME "aries-touchkey"
 
+#define ARIES_TOUCHKEY_CMD_LED_ON  0x1
+#define ARIES_TOUCHKEY_CMD_LED_OFF 0x2
 #define TM2_TOUCHKEY_CMD_LED_ON0x10
 #define TM2_TOUCHKEY_CMD_LED_OFF   0x20
 #define TM2_TOUCHKEY_BIT_PRESS_EV  BIT(3)
@@ -40,6 +43,10 @@ struct touchkey_variant {
const char *name;
u8 keycode_reg;
u8 base_reg;
+   u8 cmd_led_on;
+   u8 cmd_led_off;
+   bool no_reg;
+   bool fixed_regulator;
 };
 
 struct tm2_touchkey_data {
@@ -57,12 +64,24 @@ static struct touchkey_variant tm2_touchkey_variant = {
.name = TM2_TOUCHKEY_DEV_NAME,
.keycode_reg = 0x03,
.base_reg = 0x00,
+   .cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
+   .cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
 };
 
 static struct touchkey_variant midas_touchkey_variant = {
.name = MIDAS_TOUCHKEY_DEV_NAME,
.keycode_reg = 0x00,
.base_reg = 0x00,
+   .cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
+   .cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
+};
+
+static struct touchkey_variant aries_touchkey_variant = {
+   .name = ARIES_TOUCHKEY_DEV_NAME,
+   .no_reg = true,
+   .fixed_regulator = true,
+   .cmd_led_on = ARIES_TOUCHKEY_CMD_LED_ON,
+   .cmd_led_off = ARIES_TOUCHKEY_CMD_LED_OFF,
 };
 
 static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
@@ -75,15 +94,20 @@ static void tm2_touchkey_led_brightness_set(struct 
led_classdev *led_dev,
 
if (brightness == LED_OFF) {
volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN;
-   data = TM2_TOUCHKEY_CMD_LED_OFF;
+   data = touchkey->variant->cmd_led_off;
} else {
volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX;
-   data = TM2_TOUCHKEY_CMD_LED_ON;
+   data = touchkey->variant->cmd_led_on;
}
 
-   regulator_set_voltage(touchkey->vdd, volt, volt);
-   i2c_smbus_write_byte_data(touchkey->client,
- touchkey->variant->base_reg, data);
+   if (!touchkey->variant->fixed_regulator)
+   regulator_set_voltage(touchkey->vdd, volt, volt);
+
+   if (touchkey->variant->no_reg)
+   i2c_smbus_write_byte(touchkey->client, data);
+   else
+   i2c_smbus_write_byte_data(touchkey->client,
+ touchkey->variant->base_reg, data);
 }
 
 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
@@ -116,8 +140,11 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
int index;
int i;
 
-   data = i2c_smbus_read_byte_data(touchkey->client,
-   touchkey->variant->keycode_reg);
+   if (touchkey->variant->no_reg)
+   data = i2c_smbus_read_byte(touchkey->client);
+   else
+   data = i2c_smbus_read_byte_data(touchkey->client,
+   touchkey->variant->keycode_reg);
if (data < 0) {
dev_err(&touchkey->client->dev,
"failed to read i2c data: %d\n", data);
@@ -143,6 +170,14 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
input_sync(touchkey->input_dev);
 
 out:
+   if (touchkey->variant->fixed_regulator &&
+   data & TM2_TOUCHKEY_BIT_PRESS_EV) {
+   /* touch turns backlight on, so make sure we're in sync */
+   if (touchkey->led_dev.brightness == LED_OFF)
+   tm2_touchkey_led_brightness_set(&touchkey->led_dev,
+   LED_OFF);
+   }
+
return IRQ_HANDLED;
 }
 
@@ -251,6 +286,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
return error;
}
 
+   if (touchkey->variant->fixed_regulator)
+   tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON);
+
return 0;
 }
 
@@ -286,6 +324,7 @@ static SIMPLE_DEV_PM_OPS(tm2_touchkey_pm_ops,
 static const struct i2c_device_id tm2_touchkey_id_table[] = {
  

[PATCH 5/8] Input: tm2-touchkey: Allow specifying custom keycodes

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Not all devices use the same keycodes in the same order

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 drivers/input/keyboard/tm2-touchkey.c | 49 +++
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index a73894b8dede..ebc275ab8ad1 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -36,11 +36,6 @@
 #define TM2_TOUCHKEY_LED_VOLTAGE_MIN   250
 #define TM2_TOUCHKEY_LED_VOLTAGE_MAX   330
 
-enum {
-   TM2_TOUCHKEY_KEY_MENU = 0x1,
-   TM2_TOUCHKEY_KEY_BACK,
-};
-
 struct touchkey_variant {
const char *name;
u8 keycode_reg;
@@ -54,6 +49,8 @@ struct tm2_touchkey_data {
struct regulator *vdd;
struct regulator_bulk_data regulators[2];
struct touchkey_variant *variant;
+   u8 keycodes[4];
+   int num_keycodes;
 };
 
 static struct touchkey_variant tm2_touchkey_variant = {
@@ -116,7 +113,8 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
 {
struct tm2_touchkey_data *touchkey = devid;
int data;
-   int key;
+   int index;
+   int i;
 
data = i2c_smbus_read_byte_data(touchkey->client,
touchkey->variant->keycode_reg);
@@ -126,26 +124,20 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
goto out;
}
 
-   switch (data & TM2_TOUCHKEY_BIT_KEYCODE) {
-   case TM2_TOUCHKEY_KEY_MENU:
-   key = KEY_PHONE;
-   break;
-
-   case TM2_TOUCHKEY_KEY_BACK:
-   key = KEY_BACK;
-   break;
-
-   default:
+   index = (data & TM2_TOUCHKEY_BIT_KEYCODE) - 1;
+   if (index < 0 || index >= touchkey->num_keycodes) {
dev_warn(&touchkey->client->dev,
-"unhandled keycode, data %#02x\n", data);
+"invalid keycode index %d\n", index);
goto out;
}
 
if (data & TM2_TOUCHKEY_BIT_PRESS_EV) {
-   input_report_key(touchkey->input_dev, KEY_PHONE, 0);
-   input_report_key(touchkey->input_dev, KEY_BACK, 0);
+   for (i = 0; i < touchkey->num_keycodes; i++)
+   input_report_key(touchkey->input_dev,
+touchkey->keycodes[i], 0);
} else {
-   input_report_key(touchkey->input_dev, key, 1);
+   input_report_key(touchkey->input_dev,
+touchkey->keycodes[index], 1);
}
 
input_sync(touchkey->input_dev);
@@ -157,8 +149,10 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
 static int tm2_touchkey_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
+   struct device_node *np = client->dev.of_node;
struct tm2_touchkey_data *touchkey;
int error;
+   int i;
 
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -189,6 +183,16 @@ static int tm2_touchkey_probe(struct i2c_client *client,
/* Save VDD for easy access */
touchkey->vdd = touchkey->regulators[1].consumer;
 
+   touchkey->num_keycodes = of_property_read_variable_u8_array(np,
+   "keycodes", touchkey->keycodes, 0,
+   ARRAY_SIZE(touchkey->keycodes));
+   if (touchkey->num_keycodes <= 0) {
+   /* default keycodes */
+   touchkey->keycodes[0] = KEY_PHONE;
+   touchkey->keycodes[1] = KEY_BACK;
+   touchkey->num_keycodes = 2;
+   }
+
error = tm2_touchkey_power_enable(touchkey);
if (error) {
dev_err(&client->dev, "failed to power up device: %d\n", error);
@@ -213,8 +217,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
touchkey->input_dev->name = touchkey->variant->name;
touchkey->input_dev->id.bustype = BUS_I2C;
 
-   input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE);
-   input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK);
+   for (i = 0; i < touchkey->num_keycodes; i++)
+   input_set_capability(touchkey->input_dev, EV_KEY,
+touchkey->keycodes[i]);
 
error = input_register_device(touchkey->input_dev);
if (error) {
-- 
2.17.1



[PATCH 2/8] Input: dt-bindings: tm2-touchkey: Add support for midas touchkey

2018-12-07 Thread Paweł Chmiel
From: Simon Shields 

Document compatible for midas touchkey.

Signed-off-by: Simon Shields 
Signed-off-by: Paweł Chmiel 
---
 .../devicetree/bindings/input/cypress,tm2-touchkey.txt| 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt 
b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index 0c252d9306da..dfb3b9f0ee40 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -1,7 +1,9 @@
 Samsung tm2-touchkey
 
 Required properties:
-- compatible: must be "cypress,tm2-touchkey"
+- compatible:
+* "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
+* "cypress,midas-touchkey" - for the touchkey found on midas boards
 - reg: I2C address of the chip.
 - interrupts: interrupt to which the chip is connected (see interrupt
binding[0]).
-- 
2.17.1



[PATCH 0/8] Input: tm2-touchkey: Add support for Aries and Midas

2018-12-07 Thread Paweł Chmiel
This patches adds support for Aries (Samsung i9000) and Midsa (Samsung S3)
based devices to TM2 Touchkey driver.

Jonathan Bakker (6):
  Input: tm2-touchkey: Use predefined device name
  Input: tm2-touchkey: Correct initial brightness
  Input: tm2-touchkey: Allow specifying custom keycodes
  Input: dt-bindings: tm2-touchkey: Document new keycodes property
  Input: tm2-touchkey: Add support for aries touchkey variant
  Input: dt-bindings: tm2-touchkey: Add support for aries touchkey

Simon Shields (2):
  Input: tm2-touchkey: Add support for midas touchkey
  Input: dt-bindings: tm2-touchkey: Add support for midas touchkey

 .../bindings/input/cypress,tm2-touchkey.txt   |   9 +-
 drivers/input/keyboard/tm2-touchkey.c | 149 +-
 2 files changed, 121 insertions(+), 37 deletions(-)

-- 
2.17.1



[PATCH 1/8] Input: tm2-touchkey: Add support for midas touchkey

2018-12-07 Thread Paweł Chmiel
From: Simon Shields 

The touchkey on midas boards is almost identical.
The only real difference is that it uses the same register for both
keycode and base.

Signed-off-by: Simon Shields 
Signed-off-by: Paweł Chmiel 
---
 drivers/input/keyboard/tm2-touchkey.c | 48 ++-
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index abc266e40e17..37a5ced24009 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -22,12 +22,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-#define TM2_TOUCHKEY_DEV_NAME  "tm2-touchkey"
-#define TM2_TOUCHKEY_KEYCODE_REG   0x03
-#define TM2_TOUCHKEY_BASE_REG  0x00
+#define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey"
+#define MIDAS_TOUCHKEY_DEV_NAME "midas-touchkey"
+
 #define TM2_TOUCHKEY_CMD_LED_ON0x10
 #define TM2_TOUCHKEY_CMD_LED_OFF   0x20
 #define TM2_TOUCHKEY_BIT_PRESS_EV  BIT(3)
@@ -40,12 +41,31 @@ enum {
TM2_TOUCHKEY_KEY_BACK,
 };
 
+struct touchkey_variant {
+   const char *name;
+   u8 keycode_reg;
+   u8 base_reg;
+};
+
 struct tm2_touchkey_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct led_classdev led_dev;
struct regulator *vdd;
struct regulator_bulk_data regulators[2];
+   struct touchkey_variant *variant;
+};
+
+static struct touchkey_variant tm2_touchkey_variant = {
+   .name = "tm2-touchkey",
+   .keycode_reg = 0x03,
+   .base_reg = 0x00,
+};
+
+static struct touchkey_variant midas_touchkey_variant = {
+   .name = "midas-touchkey",
+   .keycode_reg = 0x00,
+   .base_reg = 0x00,
 };
 
 static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
@@ -66,7 +86,7 @@ static void tm2_touchkey_led_brightness_set(struct 
led_classdev *led_dev,
 
regulator_set_voltage(touchkey->vdd, volt, volt);
i2c_smbus_write_byte_data(touchkey->client,
- TM2_TOUCHKEY_BASE_REG, data);
+ touchkey->variant->base_reg, data);
 }
 
 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
@@ -99,7 +119,7 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
int key;
 
data = i2c_smbus_read_byte_data(touchkey->client,
-   TM2_TOUCHKEY_KEYCODE_REG);
+   touchkey->variant->keycode_reg);
if (data < 0) {
dev_err(&touchkey->client->dev,
"failed to read i2c data: %d\n", data);
@@ -153,6 +173,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
touchkey->client = client;
i2c_set_clientdata(client, touchkey);
 
+   touchkey->variant = (struct touchkey_variant *)
+   of_device_get_match_data(&client->dev);
+
touchkey->regulators[0].supply = "vcc";
touchkey->regulators[1].supply = "vdd";
error = devm_regulator_bulk_get(&client->dev,
@@ -187,7 +210,7 @@ static int tm2_touchkey_probe(struct i2c_client *client,
return -ENOMEM;
}
 
-   touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
+   touchkey->input_dev->name = touchkey->variant->name;
touchkey->input_dev->id.bustype = BUS_I2C;
 
input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE);
@@ -203,7 +226,7 @@ static int tm2_touchkey_probe(struct i2c_client *client,
error = devm_request_threaded_irq(&client->dev, client->irq,
  NULL, tm2_touchkey_irq_handler,
  IRQF_ONESHOT,
- TM2_TOUCHKEY_DEV_NAME, touchkey);
+ touchkey->variant->name, touchkey);
if (error) {
dev_err(&client->dev,
"failed to request threaded irq: %d\n", error);
@@ -211,7 +234,7 @@ static int tm2_touchkey_probe(struct i2c_client *client,
}
 
/* led device */
-   touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
+   touchkey->led_dev.name = touchkey->variant->name;
touchkey->led_dev.brightness = LED_FULL;
touchkey->led_dev.max_brightness = LED_ON;
touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set;
@@ -257,12 +280,19 @@ static SIMPLE_DEV_PM_OPS(tm2_touchkey_pm_ops,
 
 static const struct i2c_device_id tm2_touchkey_id_table[] = {
{ TM2_TOUCHKEY_DEV_NAME, 0 },
+   { MIDAS_TOUCHKEY_DEV_NAME, 0 },
{ },
 };
 MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table);
 
 

[PATCH v4 3/3] Input: atmel_mxt_ts: Document optional voltage regulators

2018-12-07 Thread Paweł Chmiel
Document new optional voltage regulators, which can be used
to power down/up touchscreen.

Signed-off-by: Paweł Chmiel 
Reviewed-by: Rob Herring 
---
Changes from v1:
  - Added reviewed-by
---
 .../devicetree/bindings/input/atmel,maxtouch.txt  | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt 
b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
index c88919480d37..17930ecadad3 100644
--- a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
+++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
@@ -31,6 +31,12 @@ Optional properties for main touchpad device:
 
 - reset-gpios: GPIO specifier for the touchscreen's reset pin (active low)
 
+- avdd-supply: Analog power supply. It powers up the analog channel block
+of the controller to detect the touches.
+
+- vdd-supply: Digital power supply. It powers up the digital block
+of the controller to enable i2c communication.
+
 Example:
 
touch@4b {
@@ -38,4 +44,6 @@ Example:
reg = <0x4b>;
interrupt-parent = <&gpio>;
interrupts = ;
+   avdd-supply = <&atsp_reg>;
+   vdd-supply = <&tsp_reg>;
};
-- 
2.17.1



[PATCH v4 0/3] Input: atmel_mxt_ts: Add support for optional regulators

2018-12-07 Thread Paweł Chmiel
This patch series adds optional regulator support to atmel_mxt_ts.
First patch adds regulators to driver.
Second patch ensures that device is ready for communication.
Third patch updates documentation.

Changes from v3:
  - Checkpatch fixes
  - Drop punctuation from subject of one of patches

Changes from v2:
  - Add reviewed-by to one patch
  - Move code for enabling regulators into separate method,
to make code more readable.
  - Add wait code, to ensure that device is ready for communication.

Changes from v1:
  - Enable regulators only if reset_gpio is present.
  - Switch from devm_regulator_get_optional to devm_regulator_get.

Paweł Chmiel (3):
  Input: atmel_mxt_ts: Add support for  optional regulators
  Input: atmel_mxt_ts: Wait for device be ready for communication
  Input: atmel_mxt_ts: Document optional voltage regulators

 .../bindings/input/atmel,maxtouch.txt |  8 ++
 drivers/input/touchscreen/atmel_mxt_ts.c  | 76 +--
 2 files changed, 78 insertions(+), 6 deletions(-)

-- 
2.17.1



[PATCH v4 2/3] Input: atmel_mxt_ts: Wait for device be ready for communication

2018-12-07 Thread Paweł Chmiel
According to documentation, device isn't ready for communication,
until firmware asserts the CHG line. Add missing wait for this.

Signed-off-by: Paweł Chmiel 
---
Changes from v3:
  - Fix checkpatch issues
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index 1dc8ad0da5af..3f956d07d09e 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -202,6 +202,7 @@ enum t100_type {
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
+#define MXT_POWERON_DELAY  150 /* msec */
 
 /* Command to unlock bootloader */
 #define MXT_UNLOCK_CMD_MSB 0xaa
@@ -3068,6 +3069,16 @@ static int mxt_regulator_enable(struct mxt_data *data)
msleep(MXT_REGULATOR_DELAY);
gpiod_set_value(data->reset_gpio, 1);
msleep(MXT_RESET_INVALID_CHG);
+
+retry_wait:
+   reinit_completion(&data->bl_completion);
+   data->in_bootloader = true;
+   error = mxt_wait_for_completion(data, &data->bl_completion,
+   MXT_POWERON_DELAY);
+   if (error == -EINTR)
+   goto retry_wait;
+
+   data->in_bootloader = false;
}
 
return 0;
-- 
2.17.1



[PATCH v4 1/3] Input: atmel_mxt_ts: Add support for optional regulators

2018-12-07 Thread Paweł Chmiel
This patch adds optional regulators, which can be used to power
up touchscreen. After enabling regulators, we need to wait 150msec.
This value is taken from official driver.

It was tested on Samsung Galaxy i9000 (based on Samsung S5PV210 SOC).

Signed-off-by: Paweł Chmiel 
---
Changes from v3:
  - Fix checkpatch issues
  - Drop sentence punctuation from subject of one of patches

Changes from v2:
  - Move code enabling regulators into separate method,
to make code more readable.

Changes from v1:
  - Enable regulators only if reset_gpio is present.
  - Switch from devm_regulator_get_optional to devm_regulator_get
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 65 +---
 1 file changed, 59 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index d3aacd534e9c..1dc8ad0da5af 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -194,10 +195,10 @@ enum t100_type {
 
 /* Delay times */
 #define MXT_BACKUP_TIME50  /* msec */
-#define MXT_RESET_GPIO_TIME20  /* msec */
 #define MXT_RESET_INVALID_CHG  100 /* msec */
 #define MXT_RESET_TIME 200 /* msec */
 #define MXT_RESET_TIMEOUT  3000/* msec */
+#define MXT_REGULATOR_DELAY150 /* msec */
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
@@ -323,6 +324,8 @@ struct mxt_data {
struct t7_config t7_cfg;
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
+   struct regulator *vdd_reg;
+   struct regulator *avdd_reg;
 
/* Cached parameters from object table */
u16 T5_address;
@@ -3038,6 +3041,38 @@ static const struct dmi_system_id 
chromebook_T9_suspend_dmi[] = {
{ }
 };
 
+static int mxt_regulator_enable(struct mxt_data *data)
+{
+   int error;
+
+   if (data->reset_gpio) {
+   error = regulator_enable(data->vdd_reg);
+   if (error) {
+   dev_err(&data->client->dev,
+   "Failed to enable vdd regulator: %d\n", error);
+   return error;
+   }
+
+   error = regulator_enable(data->avdd_reg);
+   if (error) {
+   dev_err(&data->client->dev,
+   "Failed to enable avdd regulator: %d\n", error);
+   return error;
+   }
+
+   /*
+* According to maXTouch power sequencing specification,
+* RESET line must be kept low until some time
+* after regulators come up to voltage
+*/
+   msleep(MXT_REGULATOR_DELAY);
+   gpiod_set_value(data->reset_gpio, 1);
+   msleep(MXT_RESET_INVALID_CHG);
+   }
+
+   return 0;
+}
+
 static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
struct mxt_data *data;
@@ -3098,6 +3133,22 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
return error;
}
 
+   data->vdd_reg = devm_regulator_get(&client->dev, "vdd");
+   if (IS_ERR(data->vdd_reg)) {
+   error = PTR_ERR(data->vdd_reg);
+   dev_err(&client->dev, "Failed to get vdd regulator: %d\n",
+   error);
+   return error;
+   }
+
+   data->avdd_reg = devm_regulator_get(&client->dev, "avdd");
+   if (IS_ERR(data->avdd_reg)) {
+   error = PTR_ERR(data->avdd_reg);
+   dev_err(&client->dev, "Failed to get avdd regulator: %d\n",
+   error);
+   return error;
+   }
+
error = devm_request_threaded_irq(&client->dev, client->irq,
  NULL, mxt_interrupt, IRQF_ONESHOT,
  client->name, data);
@@ -3108,11 +3159,9 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
 
disable_irq(client->irq);
 
-   if (data->reset_gpio) {
-   msleep(MXT_RESET_GPIO_TIME);
-   gpiod_set_value(data->reset_gpio, 1);
-   msleep(MXT_RESET_INVALID_CHG);
-   }
+   error = mxt_regulator_enable(data);
+   if (error)
+   return error;
 
error = mxt_initialize(data);
if (error)
@@ -3138,6 +3187,10 @@ static int mxt_remove(struct i2c_client *client)
struct mxt_data *data = i2c_get_clientdata(client);
 
disable_irq(data->irq);
+   if (data->res

[PATCH 0/3] iio: adc: exynos-adc: Add support for S5PV210

2018-12-07 Thread Paweł Chmiel
This patchset adds support for S5PV210 adc variant to exynos-adc driver.

Jonathan Bakker (3):
  iio: adc: exynos-adc: Add S5PV210 variant
  iio: adc: Allow selection of Exynos ADC on S5PV210
  dt-bindings: iio: adc: exynos-adc: Add S5PV210 variant

 .../bindings/iio/adc/samsung,exynos-adc.txt|  4 +++-
 drivers/iio/adc/Kconfig|  2 +-
 drivers/iio/adc/exynos_adc.c   | 14 ++
 3 files changed, 18 insertions(+), 2 deletions(-)

-- 
2.17.1



[PATCH 3/3] dt-bindings: iio: adc: exynos-adc: Add S5PV210 variant

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Add information about new compatible for S5PV210

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 .../devicetree/bindings/iio/adc/samsung,exynos-adc.txt| 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt 
b/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt
index 6c49db7f8ad2..a10c1f89037d 100644
--- a/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt
@@ -11,7 +11,7 @@ New driver handles the following
 
 Required properties:
 - compatible:  Must be "samsung,exynos-adc-v1"
-   for exynos4412/5250 and s5pv210 controllers.
+   for exynos4412/5250 controllers.
Must be "samsung,exynos-adc-v2" for
future controllers.
Must be "samsung,exynos3250-adc" for
@@ -28,6 +28,8 @@ Required properties:
the ADC in s3c2443 and compatibles
Must be "samsung,s3c6410-adc" for
the ADC in s3c6410 and compatibles
+   Must be "samsung,s5pv210-adc" for
+   the ADC in s5pv210 and compatibles
 - reg: List of ADC register address range
- The base address and range of ADC register
- The base address and range of ADC_PHY register (every
-- 
2.17.1



[PATCH 2/3] iio: adc: Allow selection of Exynos ADC on S5PV210

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Make it possible to use Exynos ADC driver on S5PV210 based devices.

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 drivers/iio/adc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index a52fea8749a9..20e126ff030e 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -274,7 +274,7 @@ config EP93XX_ADC
 
 config EXYNOS_ADC
tristate "Exynos ADC driver support"
-   depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || (OF && 
COMPILE_TEST)
+   depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210 
|| (OF && COMPILE_TEST)
depends on HAS_IOMEM
help
  Core support for the ADC block found in the Samsung EXYNOS series
-- 
2.17.1



[PATCH 1/3] iio: adc: exynos-adc: Add S5PV210 variant

2018-12-07 Thread Paweł Chmiel
From: Jonathan Bakker 

S5PV210's ADC variant is almost the same as v1 except that it has 10
channels and doesn't require the pmu register

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 drivers/iio/adc/exynos_adc.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index f10443f92e4c..fa2d2b5767f3 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -115,6 +115,7 @@
 #define MAX_ADC_V2_CHANNELS10
 #define MAX_ADC_V1_CHANNELS8
 #define MAX_EXYNOS3250_ADC_CHANNELS2
+#define MAX_S5PV210_ADC_CHANNELS   10
 
 /* Bit definitions common for ADC_V1 and ADC_V2 */
 #define ADC_CON_EN_START   (1u << 0)
@@ -282,6 +283,16 @@ static const struct exynos_adc_data exynos_adc_v1_data = {
.start_conv = exynos_adc_v1_start_conv,
 };
 
+static const struct exynos_adc_data exynos_adc_s5pv210_data = {
+   .num_channels   = MAX_S5PV210_ADC_CHANNELS,
+   .mask   = ADC_DATX_MASK,/* 12 bit ADC resolution */
+
+   .init_hw= exynos_adc_v1_init_hw,
+   .exit_hw= exynos_adc_v1_exit_hw,
+   .clear_irq  = exynos_adc_v1_clear_irq,
+   .start_conv = exynos_adc_v1_start_conv,
+};
+
 static void exynos_adc_s3c2416_start_conv(struct exynos_adc *info,
  unsigned long addr)
 {
@@ -478,6 +489,9 @@ static const struct of_device_id exynos_adc_match[] = {
}, {
.compatible = "samsung,s3c6410-adc",
.data = &exynos_adc_s3c64xx_data,
+   }, {
+   .compatible = "samsung,s5pv210-adc",
+   .data = &exynos_adc_s5pv210_data,
}, {
.compatible = "samsung,exynos-adc-v1",
.data = &exynos_adc_v1_data,
-- 
2.17.1



Re: [PATCH 2/5] media: dt-bindings: Add binding for si470x radio

2018-12-07 Thread Paweł Chmiel
Dnia piątek, 7 grudnia 2018 12:33:10 CET Hans Verkuil pisze:
> Please combine 2/5 with 5/5. No need to have two patches for these bindings.
I though that it will be better to separate patches which just adds devicetree 
support
and those adding new functionality (reset), so for example if there is more 
work needed on one of them,
the second one can still be picked (devicetree one).

Ok will do this in next version of patchset.
 
> 
> Regards,
> 
>   Hans
> 
> On 12/05/2018 04:47 PM, Paweł Chmiel wrote:
> > Add device tree bindings for si470x family radio receiver driver.
> > 
> > Signed-off-by: Paweł Chmiel 
> > ---
> >  .../devicetree/bindings/media/si470x.txt  | 24 +++
> >  1 file changed, 24 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/media/si470x.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/media/si470x.txt 
> > b/Documentation/devicetree/bindings/media/si470x.txt
> > new file mode 100644
> > index ..9294fdfd3aae
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/media/si470x.txt
> > @@ -0,0 +1,24 @@
> > +* Silicon Labs FM Radio receiver
> > +
> > +The Silicon Labs Si470x is family of FM radio receivers with receive power 
> > scan
> > +supporting 76-108 MHz, programmable through an I2C interface.
> > +Some of them includes an RDS encoder.
> > +
> > +Required Properties:
> > +- compatible: Should contain "silabs,si470x"
> > +- reg: the I2C address of the device
> > +
> > +Optional Properties:
> > +- interrupts : The interrupt number
> > +
> > +Example:
> > +
> > +&i2c2 {
> > +si470x@63 {
> > +compatible = "silabs,si470x";
> > +reg = <0x63>;
> > +
> > +interrupt-parent = <&gpj2>;
> > +interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
> > +};
> > +};
> > 
> 
> 






[PATCH v2 4/4] media: dt-bindings: Add binding for si470x radio

2018-12-07 Thread Paweł Chmiel
Add device tree bindings for si470x family radio receiver driver.

Signed-off-by: Paweł Chmiel 
---
Changes from v1:
- squashed with patch adding reset-gpio documentation
---
 .../devicetree/bindings/media/si470x.txt  | 26 +++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/si470x.txt

diff --git a/Documentation/devicetree/bindings/media/si470x.txt 
b/Documentation/devicetree/bindings/media/si470x.txt
new file mode 100644
index ..a9403558362e
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/si470x.txt
@@ -0,0 +1,26 @@
+* Silicon Labs FM Radio receiver
+
+The Silicon Labs Si470x is family of FM radio receivers with receive power scan
+supporting 76-108 MHz, programmable through an I2C interface.
+Some of them includes an RDS encoder.
+
+Required Properties:
+- compatible: Should contain "silabs,si470x"
+- reg: the I2C address of the device
+
+Optional Properties:
+- interrupts : The interrupt number
+- reset-gpios: GPIO specifier for the chips reset line
+
+Example:
+
+&i2c2 {
+si470x@63 {
+compatible = "silabs,si470x";
+reg = <0x63>;
+
+interrupt-parent = <&gpj2>;
+interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
+reset-gpios = <&gpj2 5 GPIO_ACTIVE_HIGH>;
+};
+};
-- 
2.17.1



[PATCH v2 1/4] si470x-i2c: Add device tree support

2018-12-07 Thread Paweł Chmiel
This commit enables device tree support adding simple of_match table.

Signed-off-by: Paweł Chmiel 
---
 drivers/media/radio/si470x/radio-si470x-i2c.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c 
b/drivers/media/radio/si470x/radio-si470x-i2c.c
index 9751ea1d80be..250828ddb5fa 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -527,6 +527,13 @@ static int si470x_i2c_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(si470x_i2c_pm, si470x_i2c_suspend, si470x_i2c_resume);
 #endif
 
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id si470x_of_match[] = {
+   { .compatible = "silabs,si470x" },
+   { },
+};
+MODULE_DEVICE_TABLE(of, si470x_of_match);
+#endif
 
 /*
  * si470x_i2c_driver - i2c driver interface
@@ -534,6 +541,7 @@ static SIMPLE_DEV_PM_OPS(si470x_i2c_pm, si470x_i2c_suspend, 
si470x_i2c_resume);
 static struct i2c_driver si470x_i2c_driver = {
.driver = {
.name   = "si470x",
+   .of_match_table = of_match_ptr(si470x_of_match),
 #ifdef CONFIG_PM_SLEEP
.pm = &si470x_i2c_pm,
 #endif
-- 
2.17.1



[PATCH v2 0/4] media: radio-si470x-i2c: Add device tree and reset gpio support

2018-12-07 Thread Paweł Chmiel
This patchset adds support for device tree and reset-gpios
to si470x i2c radio driver.

First two patches adds and documents device tree support.
Third patch simplifies code by using managed resource helpers.
Last two patches adds and documents new optional reset gpios support.

It was tested on Samsung Galaxy S (i9000) phone.

Changes from v1:
  - squashed patches adding/modifying dt-bindings into one patch

Paweł Chmiel (4):
  si470x-i2c: Add device tree support
  si470x-i2c: Use managed resource helpers
  si470x-i2c: Add optional reset-gpio support
  media: dt-bindings: Add binding for si470x radio

 .../devicetree/bindings/media/si470x.txt  | 26 ++
 drivers/media/radio/si470x/radio-si470x-i2c.c | 52 ---
 drivers/media/radio/si470x/radio-si470x.h |  1 +
 3 files changed, 61 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/si470x.txt

-- 
2.17.1



[PATCH v2 2/4] si470x-i2c: Use managed resource helpers

2018-12-07 Thread Paweł Chmiel
Simplify cleanup of failures by using managed resource helpers

Signed-off-by: Paweł Chmiel 
---
 drivers/media/radio/si470x/radio-si470x-i2c.c | 29 +++
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c 
b/drivers/media/radio/si470x/radio-si470x-i2c.c
index 250828ddb5fa..a7ac09c55188 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -350,7 +350,7 @@ static int si470x_i2c_probe(struct i2c_client *client,
unsigned char version_warning = 0;
 
/* private data allocation and initialization */
-   radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL);
+   radio = devm_kzalloc(&client->dev, sizeof(*radio), GFP_KERNEL);
if (!radio) {
retval = -ENOMEM;
goto err_initial;
@@ -370,7 +370,7 @@ static int si470x_i2c_probe(struct i2c_client *client,
retval = v4l2_device_register(&client->dev, &radio->v4l2_dev);
if (retval < 0) {
dev_err(&client->dev, "couldn't register v4l2_device\n");
-   goto err_radio;
+   goto err_initial;
}
 
v4l2_ctrl_handler_init(&radio->hdl, 2);
@@ -396,14 +396,14 @@ static int si470x_i2c_probe(struct i2c_client *client,
radio->registers[POWERCFG] = POWERCFG_ENABLE;
if (si470x_set_register(radio, POWERCFG) < 0) {
retval = -EIO;
-   goto err_ctrl;
+   goto err_all;
}
msleep(110);
 
/* get device and chip versions */
if (si470x_get_all_registers(radio) < 0) {
retval = -EIO;
-   goto err_ctrl;
+   goto err_all;
}
dev_info(&client->dev, "DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
radio->registers[DEVICEID], 
radio->registers[SI_CHIPID]);
@@ -430,10 +430,10 @@ static int si470x_i2c_probe(struct i2c_client *client,
 
/* rds buffer allocation */
radio->buf_size = rds_buf * 3;
-   radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL);
+   radio->buffer = devm_kmalloc(&client->dev, radio->buf_size, GFP_KERNEL);
if (!radio->buffer) {
retval = -EIO;
-   goto err_ctrl;
+   goto err_all;
}
 
/* rds buffer configuration */
@@ -441,12 +441,13 @@ static int si470x_i2c_probe(struct i2c_client *client,
radio->rd_index = 0;
init_waitqueue_head(&radio->read_queue);
 
-   retval = request_threaded_irq(client->irq, NULL, si470x_i2c_interrupt,
-   IRQF_TRIGGER_FALLING | IRQF_ONESHOT, DRIVER_NAME,
-   radio);
+   retval = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+  si470x_i2c_interrupt,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  DRIVER_NAME, radio);
if (retval) {
dev_err(&client->dev, "Failed to register interrupt\n");
-   goto err_rds;
+   goto err_all;
}
 
/* register video device */
@@ -460,15 +461,9 @@ static int si470x_i2c_probe(struct i2c_client *client,
 
return 0;
 err_all:
-   free_irq(client->irq, radio);
-err_rds:
-   kfree(radio->buffer);
-err_ctrl:
v4l2_ctrl_handler_free(&radio->hdl);
 err_dev:
v4l2_device_unregister(&radio->v4l2_dev);
-err_radio:
-   kfree(radio);
 err_initial:
return retval;
 }
@@ -481,9 +476,7 @@ static int si470x_i2c_remove(struct i2c_client *client)
 {
struct si470x_device *radio = i2c_get_clientdata(client);
 
-   free_irq(client->irq, radio);
video_unregister_device(&radio->videodev);
-   kfree(radio);
 
return 0;
 }
-- 
2.17.1



[PATCH v2 3/4] si470x-i2c: Add optional reset-gpio support

2018-12-07 Thread Paweł Chmiel
If reset-gpio is defined, use it to bring device out of reset.
Without this, it's not possible to access si470x registers.

Signed-off-by: Paweł Chmiel 
---
 drivers/media/radio/si470x/radio-si470x-i2c.c | 15 +++
 drivers/media/radio/si470x/radio-si470x.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c 
b/drivers/media/radio/si470x/radio-si470x-i2c.c
index a7ac09c55188..15eea2b2c90f 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "radio-si470x.h"
@@ -392,6 +393,17 @@ static int si470x_i2c_probe(struct i2c_client *client,
radio->videodev.release = video_device_release_empty;
video_set_drvdata(&radio->videodev, radio);
 
+   radio->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset",
+   GPIOD_OUT_LOW);
+   if (IS_ERR(radio->gpio_reset)) {
+   retval = PTR_ERR(radio->gpio_reset);
+   dev_err(&client->dev, "Failed to request gpio: %d\n", retval);
+   goto err_all;
+   }
+
+   if (radio->gpio_reset)
+   gpiod_set_value(radio->gpio_reset, 1);
+
/* power up : need 110ms */
radio->registers[POWERCFG] = POWERCFG_ENABLE;
if (si470x_set_register(radio, POWERCFG) < 0) {
@@ -478,6 +490,9 @@ static int si470x_i2c_remove(struct i2c_client *client)
 
video_unregister_device(&radio->videodev);
 
+   if (radio->gpio_reset)
+   gpiod_set_value(radio->gpio_reset, 0);
+
return 0;
 }
 
diff --git a/drivers/media/radio/si470x/radio-si470x.h 
b/drivers/media/radio/si470x/radio-si470x.h
index 35fa0f3bbdd2..6fd6a399cb77 100644
--- a/drivers/media/radio/si470x/radio-si470x.h
+++ b/drivers/media/radio/si470x/radio-si470x.h
@@ -189,6 +189,7 @@ struct si470x_device {
 
 #if IS_ENABLED(CONFIG_I2C_SI470X)
struct i2c_client *client;
+   struct gpio_desc *gpio_reset;
 #endif
 };
 
-- 
2.17.1



[PATCH] ARM: dts: s5pv210: Add s5p-jpeg codec node.

2018-11-30 Thread Paweł Chmiel
This commit adds node for s5p-jpeg codec,
which is present in S5PV210 SOC.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/boot/dts/s5pv210.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/s5pv210.dtsi b/arch/arm/boot/dts/s5pv210.dtsi
index 75f454a210d6..12eac8930eac 100644
--- a/arch/arm/boot/dts/s5pv210.dtsi
+++ b/arch/arm/boot/dts/s5pv210.dtsi
@@ -627,6 +627,15 @@
samsung,lcd-wb;
};
};
+
+   jpeg_codec: jpeg-codec@fb60 {
+   compatible = "samsung,s5pv210-jpeg";
+   reg = <0xfb60 0x1000>;
+   interrupt-parent = <&vic2>;
+   interrupts = <8>;
+   clocks = <&clocks CLK_JPEG>;
+   clock-names = "jpeg";
+   };
};
 };
 
-- 
2.17.1



[PATCH v4 5/5] dt-bindings: samsung: Document bindings for SGH-T959P board

2018-07-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Document the binding for Samsung Galaxy S Fascinate 4G (SGH-T959P).

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
Acked-by: Rob Herring 
--
Changes from v2:
  - Added Acked-by

Changes from v1:
  - Added missing commit msg.
--
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index 3fa287a86300..37e96e48c48c 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -3,6 +3,7 @@
 Required root node properties:
 - compatible = should be one or more of the following.
- "samsung,aries"   - for S5PV210-based Samsung Aries board.
+   - "samsung,fascinate4g" - for S5PV210-based Samsung Galaxy S Fascinate 
4G (SGH-T959P) board.
- "samsung,galaxys" - for S5PV210-based Samsung Galaxy S (i9000)  
board.
- "samsung,artik5"  - for Exynos3250-based Samsung ARTIK5 module.
- "samsung,artik5-eval" - for Exynos3250-based Samsung ARTIK5 eval 
board.
-- 
2.7.4



[PATCH v4 2/5] ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone

2018-07-07 Thread Paweł Chmiel
This DTS file have initial support Samsung Galaxy S phone,
also known as i9000.
It belongs to Samsung Aries devices family.
Initial version have support for:
- sdcard
- internal memory
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Paweł Chmiel 

--
Changes from v1:
  - Added missing commit msg
  - Removed duplicated and unneeded headers
  - Added stdout-path
  - Added information why we hardcode bootargs
---
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/s5pv210-galaxys.dts | 77 +++
 2 files changed, 78 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 7e2424957809..522ebdca1d3d 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-smdk6410.dtb
 dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
+   s5pv210-galaxys.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
s5pv210-smdkv210.dtb \
diff --git a/arch/arm/boot/dts/s5pv210-galaxys.dts 
b/arch/arm/boot/dts/s5pv210-galaxys.dts
new file mode 100644
index ..842276749717
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-galaxys.dts
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210-aries.dtsi"
+
+/ {
+   model = "Samsung Galaxy S1 (GT-I9000) based on S5PV210";
+   compatible = "samsung,galaxys", "samsung,aries", "samsung,s5pv210";
+
+   chosen {
+   stdout-path = &uart2;
+   /*
+* It's hard to change those parameters in stock bootloader,
+* since it requires special hardware/cable.
+* Let's hardocde bootargs for now, till u-boot port is 
finished,
+* with which it should be easier.
+*/
+   bootargs = "root=/dev/mmcblk2p1 rw rootwait ignore_loglevel 
earlyprintk";
+   };
+
+   nand_pwrseq: nand-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpj2 7 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&massmemory_en>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   power {
+   label = "power";
+   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+
+   vol-down {
+   label = "volume_down";
+   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   vol-up {
+   label = "volume_up";
+   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   home {
+   label = "home";
+   gpios = <&gph3 5 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+   };
+};
+
+&pinctrl0 {
+   massmemory_en: massmemory-en {
+   samsung,pins = "gpj2-7";
+   samsung,pin-function = ;
+   samsung,pin-pud = ;
+   samsung,pin-drv = ;
+   };
+};
+
+&sdhci0 {
+   bus-width = <4>;
+   non-removable;
+   mmc-pwrseq = <&nand_pwrseq>;
+   pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4>;
+   pinctrl-names = "default";
+   status = "okay";
+};
-- 
2.7.4



[PATCH v4 0/5] Initial support for Samsung Galaxy S and Galaxy S 4G

2018-07-07 Thread Paweł Chmiel
This patch series adds support for Samsung Galaxy S and Galaxy S 4G.
Both are commercial phone based on Aries family.

Changes from v3:
  - Removed already applied patches
  - Fixed dts warnings in s5pv210-aries.dtsi

Changes from v2:
  - Restored pinctrl nodes order
  - Correct order of nodes in aries dtsi file
  - Added Reviewed-by to one of patches
  - Added Acked-by to one of patches
  - Squashed two patches updating samsung-boards documentation 

Changes from v1:
  - Removed duplicated and unneeded headers
  - Corrected node names
  - Formatting fixes
  - Removed unneeded pinctrl and sorted entries
  - Set correct interrupt type for max8998 pmic
  - Add missing regulators
  - Added missing commit msg
  - Added stdout-path
  - Added information why we hardcode bootargs
  - Added new patch which adds information, that there are samsung boards,
not using exynos bases soc.
  - Split patch updating s5pv210_defconfig into three parts.
First is result of make savedefconfig, second adds drivers required
by both devices and last adds some options, which are usefull in booting
typical Linux distribution.

Jonathan Bakker (2):
  ARM: dts: s5pv210: Add initial DTS for SGH-T959P phone
  dt-bindings: samsung: Document bindings for SGH-T959P board

Paweł Chmiel (3):
  ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones
  ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone
  dt-bindings: samsung: Document bindings for Samsung aries boards

 .../bindings/arm/samsung/samsung-boards.txt|   5 +-
 arch/arm/boot/dts/Makefile |   2 +
 arch/arm/boot/dts/s5pv210-aries.dtsi   | 419 +
 arch/arm/boot/dts/s5pv210-fascinate4g.dts  |  45 +++
 arch/arm/boot/dts/s5pv210-galaxys.dts  |  77 
 5 files changed, 547 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi
 create mode 100644 arch/arm/boot/dts/s5pv210-fascinate4g.dts
 create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts

-- 
2.7.4



[PATCH v4 3/5] ARM: dts: s5pv210: Add initial DTS for SGH-T959P phone

2018-07-07 Thread Paweł Chmiel
From: Jonathan Bakker 

This DTS file have initial support Samsung SGH-T959P phone,
also known as Samsung Galaxy S 4G or fascinate4g.
It belongs to Samsung Aries devices family.
Initial version have support for:
- sdcard
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---

Changes from v1:
  - Added missing commit msg
  - Removed duplicated and unneeded headers
  - Added stdout-path
  - Added information why we hardcode bootargs
---
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/s5pv210-fascinate4g.dts | 45 +++
 2 files changed, 46 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-fascinate4g.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 522ebdca1d3d..d00e995875bb 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-smdk6410.dtb
 dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
+   s5pv210-fascinate4g.dtb \
s5pv210-galaxys.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
diff --git a/arch/arm/boot/dts/s5pv210-fascinate4g.dts 
b/arch/arm/boot/dts/s5pv210-fascinate4g.dts
new file mode 100644
index ..ccf761b1babf
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-fascinate4g.dts
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210-aries.dtsi"
+
+/ {
+   model = "Samsung Galaxy S Fascinate 4G (SGH-T959P) based on S5PV210";
+   compatible = "samsung,fascinate4g", "samsung,aries", "samsung,s5pv210";
+
+   chosen {
+   stdout-path = &uart2;
+   /*
+* It's hard to change those parameters in stock bootloader,
+* since it requires special hardware/cable.
+* Let's hardocde bootargs for now, till u-boot port is 
finished,
+* with which it should be easier.
+*/
+   bootargs = "root=/dev/mmcblk1p1 rw rootwait ignore_loglevel 
earlyprintk";
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   power {
+   label = "power";
+   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+
+   vol-down {
+   label = "volume_down";
+   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   vol-up {
+   label = "volume_up";
+   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+};
-- 
2.7.4



[PATCH v4 4/5] dt-bindings: samsung: Document bindings for Samsung aries boards

2018-07-07 Thread Paweł Chmiel
Document the binding for Samsung Galaxy S (i9000) phone
and whole Samsung Aries devices family (based on S5PV210).

Also because this is first not Exynos-based devices, document this information
at beginning of file.

Signed-off-by: Paweł Chmiel 
Reviewed-by: Rob Herring 
--
Changes from v2:
  - Squashed with patch which was documenting existence
of non Exynos-based boards
  - Added reviewed-by

Changes from v1:
  - Added missing commit msg.
--
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index 14510b215480..3fa287a86300 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -1,7 +1,9 @@
-* Samsung's Exynos SoC based boards
+* Samsung's Exynos and S5P SoC based boards
 
 Required root node properties:
 - compatible = should be one or more of the following.
+   - "samsung,aries"   - for S5PV210-based Samsung Aries board.
+   - "samsung,galaxys" - for S5PV210-based Samsung Galaxy S (i9000)  
board.
- "samsung,artik5"  - for Exynos3250-based Samsung ARTIK5 module.
- "samsung,artik5-eval" - for Exynos3250-based Samsung ARTIK5 eval 
board.
- "samsung,monk"- for Exynos3250-based Samsung Simband board.
-- 
2.7.4



[PATCH v4 1/5] ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones

2018-07-07 Thread Paweł Chmiel
This DTS file have initial support Samsung Aries based phones.
Initial version have support for:
- sdcard
- internal memory (present only on non 4g variant)
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Paweł Chmiel 
---
Changes from v3:
  - Fix dts warnings

Changes from v2:
  - Restored pinctrl nodes order
  - Correct order of nodes

Changes from v1:
  - Removed duplicated and unneeded headers
  - Corrected node names
  - Added missing spaces
  - Removed unneeded pinctrl and sorted entries
  - Set correct interrupt type for max8998 pmic
  - Add missing regulators
---
---
 arch/arm/boot/dts/s5pv210-aries.dtsi | 419 +++
 1 file changed, 419 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi

diff --git a/arch/arm/boot/dts/s5pv210-aries.dtsi 
b/arch/arm/boot/dts/s5pv210-aries.dtsi
new file mode 100644
index ..575094ea7024
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-aries.dtsi
@@ -0,0 +1,419 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Samsung's S5PV210 based Galaxy Aries board device tree source
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210.dtsi"
+
+/ {
+   compatible = "samsung,aries", "samsung,s5pv210";
+
+   aliases {
+   i2c6 = &i2c_pmic;
+   i2c9 = &i2c_fuel;
+   };
+
+   memory@3000 {
+   device_type = "memory";
+   reg = <0x3000 0x0500
+   0x4000 0x1000
+   0x5000 0x0800>;
+   };
+
+   wifi_pwrseq: wifi-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpg1 2 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&wlan_gpio_rst>;
+   post-power-on-delay-ms = <500>;
+   power-off-delay-us = <500>;
+   };
+
+   i2c_pmic: i2c-gpio-0 {
+   compatible = "i2c-gpio";
+   sda-gpios = <&gpj4 0 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+   scl-gpios = <&gpj4 3 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+   i2c-gpio,delay-us = <2>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   pmic@66 {
+   compatible = "maxim,max8998";
+   reg = <0x66>;
+   interrupt-parent = <&gph0>;
+   interrupts = <7 IRQ_TYPE_EDGE_FALLING>;
+
+   max8998,pmic-buck1-default-dvs-idx = <1>;
+   max8998,pmic-buck1-dvs-gpios = <&gph0 3 
GPIO_ACTIVE_HIGH>,
+   <&gph0 4 
GPIO_ACTIVE_HIGH>;
+   max8998,pmic-buck1-dvs-voltage = <1275000>, <120>,
+   <105>, <95>;
+
+   max8998,pmic-buck2-default-dvs-idx = <0>;
+   max8998,pmic-buck2-dvs-gpio = <&gph0 5 
GPIO_ACTIVE_HIGH>;
+   max8998,pmic-buck2-dvs-voltage = <110>, <100>;
+
+   regulators {
+   ldo2_reg: LDO2 {
+   regulator-name = "VALIVE_1.2V";
+   regulator-min-microvolt = <120>;
+   regulator-max-microvolt = <120>;
+   regulator-always-on;
+
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   };
+   };
+
+   ldo3_reg: LDO3 {
+   regulator-name = "VUSB_1.1V";
+   regulator-min-microvolt = <110>;
+   regulator-max-microvolt = <110>;
+
+   regulator-state-mem {
+   regulator-off-in-suspend;
+   };
+   };
+
+   ldo4_reg: LDO4 {
+   regulator-name = "VADC_3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+
+   regulator-state-mem {
+  

Re: [PATCH v4 0/5] Initial support for Samsung Galaxy S and Galaxy S 4G

2018-07-10 Thread Paweł Chmiel
On Tuesday, July 10, 2018 2:05:04 PM CEST Pavel Machek wrote:
> Hi!
> 
> > This patch series adds support for Samsung Galaxy S and Galaxy S 4G.
> > Both are commercial phone based on Aries family.
> 
> Thanks for doing this. What kind of userspace are your running?
> 
> (I do have N900 here running Debian and PostmarketOS, and Droid 4
> running Maemo Leste)

Currently i'm running arch linux arm (but wanted to try PostmarketOS also).

If anyone is interested/wanted to help:
https://github.com/PabloPL/linux -> all kernel development is done here (there 
are more working things than in this patchset)
https://github.com/xc-racer99/u-boot-galaxys4g -> here is initlal port of uboot 
for aries family. It can be flashed as kernel (more details in wiki)

> 
> Best regards,
>   Pavel
>   
> 


[PATCH v2 00/10] Initial support for Samsung Galaxy S and Galaxy S 4G

2018-06-27 Thread Paweł Chmiel
This patch series adds support for Samsung Galaxy S and Galaxy S 4G.
Both are commercial phone based on Aries family.

Changes from v1:
  - Removed duplicated and unneeded headers
  - Corrected node names
  - Formatting fixes
  - Removed unneeded pinctrl and sorted entries
  - Set correct interrupt type for max8998 pmic
  - Add missing regulators
  - Added missing commit msg
  - Added stdout-path
  - Added information why we hardcode bootargs
  - Added new patch which adds information, that there are samsung boards,
not using exynos bases soc.
  - Split patch updating s5pv210_defconfig into three parts.
First is result of make savedefconfig, second adds drivers required
by both devices and last adds some options, which are usefull in booting
typical Linux distribution.

Jonathan Bakker (2):
  ARM: dts: s5pv210: Add initial DTS for SGH-T959P phone
  dt-bindings: samsung: Document bindings for SGH-T959P board

Paweł Chmiel (8):
  ARM: dts: s5pv210: Add missing interrupt-controller property to gph2
  ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones
  ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone
  dt-bindings: samsung: Add S5PV210 as possible soc in Samsung boards
  dt-bindings: samsung: Document bindings for Samsung aries boards
  ARM: s5pv210_defconfig: Run make savedefconfig
  ARM: s5pv210_defconfig: Enable drivers for Samsung Aries based phones
  ARM: s5pv210_defconfig: Enable options needed to boot typical Linux
distro

 .../bindings/arm/samsung/samsung-boards.txt|   5 +-
 arch/arm/boot/dts/Makefile |   2 +
 arch/arm/boot/dts/s5pv210-aries.dtsi   | 413 +
 arch/arm/boot/dts/s5pv210-fascinate4g.dts  |  45 +++
 arch/arm/boot/dts/s5pv210-galaxys.dts  |  77 
 arch/arm/boot/dts/s5pv210-pinctrl.dtsi |   2 +
 arch/arm/configs/s5pv210_defconfig |  49 ++-
 7 files changed, 589 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi
 create mode 100644 arch/arm/boot/dts/s5pv210-fascinate4g.dts
 create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts

-- 
2.7.4



[PATCH v2 10/10] ARM: s5pv210_defconfig: Enable options needed to boot typical Linux distro

2018-06-27 Thread Paweł Chmiel
This commit enables few options which are required to boot
typical Linux distro. It was tested by booting ArchLinux ARM
from sdcard.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/configs/s5pv210_defconfig | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index f719e7f9a655..a077597369f1 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -1,5 +1,7 @@
+CONFIG_SYSVIPC=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
+CONFIG_CGROUPS=y
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_SYSFS_DEPRECATED_V2=y
 CONFIG_BLK_DEV_INITRD=y
@@ -18,8 +20,18 @@ CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 
initrd=0x2080,8M console=ttyS
 CONFIG_VFP=y
 CONFIG_NEON=y
 CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
 CONFIG_CFG80211=m
+CONFIG_MAC80211=m
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
@@ -63,6 +75,8 @@ CONFIG_RTC_DRV_MAX8998=m
 CONFIG_PHY_SAMSUNG_USB2=m
 CONFIG_PHY_S5PV210_USB2=y
 CONFIG_EXT2_FS=y
+CONFIG_EXT4_FS=y
+CONFIG_AUTOFS4_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
 CONFIG_TMPFS=y
@@ -72,6 +86,7 @@ CONFIG_ROMFS_FS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_UTF8=y
 CONFIG_DEBUG_INFO=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_KERNEL=y
-- 
2.7.4



[PATCH v2 03/10] ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone

2018-06-27 Thread Paweł Chmiel
This DTS file have initial support Samsung Galaxy S phone,
also known as i9000.
It belongs to Samsung Aries devices family.
Initial version have support for:
- sdcard
- internal memory
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Paweł Chmiel 

--
Changes from v1:
  - Added missing commit msg
  - Removed duplicated and unneeded headers
  - Added stdout-path
  - Added information why we hardcode bootargs
---
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/s5pv210-galaxys.dts | 77 +++
 2 files changed, 78 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 7e2424957809..522ebdca1d3d 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-smdk6410.dtb
 dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
+   s5pv210-galaxys.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
s5pv210-smdkv210.dtb \
diff --git a/arch/arm/boot/dts/s5pv210-galaxys.dts 
b/arch/arm/boot/dts/s5pv210-galaxys.dts
new file mode 100644
index ..842276749717
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-galaxys.dts
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210-aries.dtsi"
+
+/ {
+   model = "Samsung Galaxy S1 (GT-I9000) based on S5PV210";
+   compatible = "samsung,galaxys", "samsung,aries", "samsung,s5pv210";
+
+   chosen {
+   stdout-path = &uart2;
+   /*
+* It's hard to change those parameters in stock bootloader,
+* since it requires special hardware/cable.
+* Let's hardocde bootargs for now, till u-boot port is 
finished,
+* with which it should be easier.
+*/
+   bootargs = "root=/dev/mmcblk2p1 rw rootwait ignore_loglevel 
earlyprintk";
+   };
+
+   nand_pwrseq: nand-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpj2 7 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&massmemory_en>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   power {
+   label = "power";
+   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+
+   vol-down {
+   label = "volume_down";
+   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   vol-up {
+   label = "volume_up";
+   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   home {
+   label = "home";
+   gpios = <&gph3 5 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+   };
+};
+
+&pinctrl0 {
+   massmemory_en: massmemory-en {
+   samsung,pins = "gpj2-7";
+   samsung,pin-function = ;
+   samsung,pin-pud = ;
+   samsung,pin-drv = ;
+   };
+};
+
+&sdhci0 {
+   bus-width = <4>;
+   non-removable;
+   mmc-pwrseq = <&nand_pwrseq>;
+   pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4>;
+   pinctrl-names = "default";
+   status = "okay";
+};
-- 
2.7.4



[PATCH v2 09/10] ARM: s5pv210_defconfig: Enable drivers for Samsung Aries based phones

2018-06-27 Thread Paweł Chmiel
Enable config options required for Samsung Aries based phones.
ARM_APPENDED_DTB is also needed, because stock bootloader
does not support loading dtb files.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/configs/s5pv210_defconfig | 33 +++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index 9c862d366fb3..f719e7f9a655 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -13,9 +13,12 @@ CONFIG_SOLARIS_X86_PARTITION=y
 CONFIG_ARCH_S5PV210=y
 CONFIG_VMSPLIT_2G=y
 CONFIG_PREEMPT=y
+CONFIG_ARM_APPENDED_DTB=y
 CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x2080,8M 
console=ttySAC1,115200 init=/linuxrc"
 CONFIG_VFP=y
 CONFIG_NEON=y
+CONFIG_NET=y
+CONFIG_CFG80211=m
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
@@ -23,16 +26,42 @@ CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y
+CONFIG_NETDEVICES=y
+CONFIG_BRCMFMAC=m
 CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_KEYBOARD is not set
+CONFIG_KEYBOARD_GPIO=y
 # CONFIG_INPUT_MOUSE is not set
 CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_SAMSUNG=y
 CONFIG_SERIAL_SAMSUNG_CONSOLE=y
 CONFIG_HW_RANDOM=y
+CONFIG_I2C_GPIO=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_BATTERY_MAX17040=y
 # CONFIG_HWMON is not set
-# CONFIG_USB_SUPPORT is not set
+CONFIG_MFD_MAX8998=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_MAX8998=y
+CONFIG_DRM=y
+CONFIG_DRM_EXYNOS=y
+CONFIG_DRM_EXYNOS_FIMD=y
+CONFIG_DRM_EXYNOS_DPI=y
+CONFIG_USB=y
+CONFIG_USB_OTG=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_EXYNOS=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_EXYNOS=y
+CONFIG_USB_DWC2=y
+CONFIG_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_S3C=y
+CONFIG_MMC_SDHCI_S3C_DMA=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_MAX8998=m
+CONFIG_PHY_SAMSUNG_USB2=m
+CONFIG_PHY_S5PV210_USB2=y
 CONFIG_EXT2_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
-- 
2.7.4



[PATCH v2 08/10] ARM: s5pv210_defconfig: Run make savedefconfig

2018-06-27 Thread Paweł Chmiel
This is result of running savedefconfig.
It's preparation for adding support for Samsung Aries devices.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/configs/s5pv210_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index 09b5a7386414..9c862d366fb3 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -13,7 +13,6 @@ CONFIG_SOLARIS_X86_PARTITION=y
 CONFIG_ARCH_S5PV210=y
 CONFIG_VMSPLIT_2G=y
 CONFIG_PREEMPT=y
-CONFIG_AEABI=y
 CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x2080,8M 
console=ttySAC1,115200 init=/linuxrc"
 CONFIG_VFP=y
 CONFIG_NEON=y
-- 
2.7.4



[PATCH v2 02/10] ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones

2018-06-27 Thread Paweł Chmiel
This DTS file have initial support Samsung Aries based phones.
Initial version have support for:
- sdcard
- internal memory (present only on non 4g variant)
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Paweł Chmiel 
---

Changes from v1:
  - Removed duplicated and unneeded headers
  - Corrected node names
  - Added missing spaces
  - Removed unneeded pinctrl and sorted entries
  - Set correct interrupt type for max8998 pmic
  - Add missing regulators
---
---
 arch/arm/boot/dts/s5pv210-aries.dtsi | 423 +++
 1 file changed, 423 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi

diff --git a/arch/arm/boot/dts/s5pv210-aries.dtsi 
b/arch/arm/boot/dts/s5pv210-aries.dtsi
new file mode 100644
index ..61b6cf76265f
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-aries.dtsi
@@ -0,0 +1,423 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Samsung's S5PV210 based Galaxy Aries board device tree source
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210.dtsi"
+
+/ {
+   compatible = "samsung,aries", "samsung,s5pv210";
+
+   aliases {
+   i2c6 = &i2c_pmic;
+   i2c9 = &i2c_fuel;
+   };
+
+   memory@3000 {
+   device_type = "memory";
+   reg = <0x3000 0x0500
+   0x4000 0x1000
+   0x5000 0x0800>;
+   };
+
+   wifi_pwrseq: wifi-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpg1 2 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&wlan_gpio_rst>;
+   post-power-on-delay-ms = <500>;
+   power-off-delay-us = <500>;
+   };
+
+   i2c_pmic: i2c-gpio-0 {
+   compatible = "i2c-gpio";
+   sda-gpios = <&gpj4 0 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+   scl-gpios = <&gpj4 3 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+   i2c-gpio,delay-us = <2>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   pmic@66 {
+   compatible = "maxim,max8998";
+   reg = <0x66>;
+   interrupt-parent = <&gph0>;
+   interrupts = <7 IRQ_TYPE_EDGE_FALLING>;
+
+   max8998,pmic-buck1-default-dvs-idx = <1>;
+   max8998,pmic-buck1-dvs-gpios = <&gph0 3 
GPIO_ACTIVE_HIGH>,
+   <&gph0 4 
GPIO_ACTIVE_HIGH>;
+   max8998,pmic-buck1-dvs-voltage = <1275000>, <120>,
+   <105>, <95>;
+
+   max8998,pmic-buck2-default-dvs-idx = <0>;
+   max8998,pmic-buck2-dvs-gpio = <&gph0 5 
GPIO_ACTIVE_HIGH>;
+   max8998,pmic-buck2-dvs-voltage = <110>, <100>;
+
+   regulators {
+   ldo2_reg: LDO2 {
+   regulator-name = "VALIVE_1.2V";
+   regulator-min-microvolt = <120>;
+   regulator-max-microvolt = <120>;
+   regulator-always-on;
+
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   };
+   };
+
+   ldo3_reg: LDO3 {
+   regulator-name = "VUSB_1.1V";
+   regulator-min-microvolt = <110>;
+   regulator-max-microvolt = <110>;
+
+   regulator-state-mem {
+   regulator-off-in-suspend;
+   };
+   };
+
+   ldo4_reg: LDO4 {
+   regulator-name = "VADC_3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+
+   regulator-state-mem {
+   regulator-off-in-suspend;
+   };
+  

[PATCH v2 06/10] dt-bindings: samsung: Document bindings for Samsung aries boards

2018-06-27 Thread Paweł Chmiel
Document the binding for Samsung Galaxy S (i9000) phone.
Also add binding for whole Samsung Aries devices family (based on S5PV210).

Signed-off-by: Paweł Chmiel 
--

Changes from v1:
  - Added missing commit msg.
--
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index 175f669d9bb6..3fa287a86300 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -2,6 +2,8 @@
 
 Required root node properties:
 - compatible = should be one or more of the following.
+   - "samsung,aries"   - for S5PV210-based Samsung Aries board.
+   - "samsung,galaxys" - for S5PV210-based Samsung Galaxy S (i9000)  
board.
- "samsung,artik5"  - for Exynos3250-based Samsung ARTIK5 module.
- "samsung,artik5-eval" - for Exynos3250-based Samsung ARTIK5 eval 
board.
- "samsung,monk"- for Exynos3250-based Samsung Simband board.
-- 
2.7.4



[PATCH v2 07/10] dt-bindings: samsung: Document bindings for SGH-T959P board

2018-06-27 Thread Paweł Chmiel
From: Jonathan Bakker 

Document the binding for Samsung Galaxy S Fascinate 4G (SGH-T959P).

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
--

Changes from v1:
  - Added missing commit msg.
--
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index 3fa287a86300..37e96e48c48c 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -3,6 +3,7 @@
 Required root node properties:
 - compatible = should be one or more of the following.
- "samsung,aries"   - for S5PV210-based Samsung Aries board.
+   - "samsung,fascinate4g" - for S5PV210-based Samsung Galaxy S Fascinate 
4G (SGH-T959P) board.
- "samsung,galaxys" - for S5PV210-based Samsung Galaxy S (i9000)  
board.
- "samsung,artik5"  - for Exynos3250-based Samsung ARTIK5 module.
- "samsung,artik5-eval" - for Exynos3250-based Samsung ARTIK5 eval 
board.
-- 
2.7.4



[PATCH v2 04/10] ARM: dts: s5pv210: Add initial DTS for SGH-T959P phone

2018-06-27 Thread Paweł Chmiel
From: Jonathan Bakker 

This DTS file have initial support Samsung SGH-T959P phone,
also known as Samsung Galaxy S 4G or fascinate4g.
It belongs to Samsung Aries devices family.
Initial version have support for:
- sdcard
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---

Changes from v1:
  - Added missing commit msg
  - Removed duplicated and unneeded headers
  - Added stdout-path
  - Added information why we hardcode bootargs
---
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/s5pv210-fascinate4g.dts | 45 +++
 2 files changed, 46 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-fascinate4g.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 522ebdca1d3d..d00e995875bb 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-smdk6410.dtb
 dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
+   s5pv210-fascinate4g.dtb \
s5pv210-galaxys.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
diff --git a/arch/arm/boot/dts/s5pv210-fascinate4g.dts 
b/arch/arm/boot/dts/s5pv210-fascinate4g.dts
new file mode 100644
index ..ccf761b1babf
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-fascinate4g.dts
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210-aries.dtsi"
+
+/ {
+   model = "Samsung Galaxy S Fascinate 4G (SGH-T959P) based on S5PV210";
+   compatible = "samsung,fascinate4g", "samsung,aries", "samsung,s5pv210";
+
+   chosen {
+   stdout-path = &uart2;
+   /*
+* It's hard to change those parameters in stock bootloader,
+* since it requires special hardware/cable.
+* Let's hardocde bootargs for now, till u-boot port is 
finished,
+* with which it should be easier.
+*/
+   bootargs = "root=/dev/mmcblk1p1 rw rootwait ignore_loglevel 
earlyprintk";
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   power {
+   label = "power";
+   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+
+   vol-down {
+   label = "volume_down";
+   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   vol-up {
+   label = "volume_up";
+   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+};
-- 
2.7.4



[PATCH v2 05/10] dt-bindings: samsung: Add S5PV210 as possible soc in Samsung boards

2018-06-27 Thread Paweł Chmiel
There are Samsung devices, which are not Exynos-based boards,
like it's in case of S5PV210. Document this information at beginning
of file.

Signed-off-by: Paweł Chmiel 
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index 14510b215480..175f669d9bb6 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -1,4 +1,4 @@
-* Samsung's Exynos SoC based boards
+* Samsung's Exynos and S5P SoC based boards
 
 Required root node properties:
 - compatible = should be one or more of the following.
-- 
2.7.4



[PATCH v2 01/10] ARM: dts: s5pv210: Add missing interrupt-controller property to gph2

2018-06-27 Thread Paweł Chmiel
Adds missing interrupt-controller property to gph2 block,
to silence following warnings during build
  /soc/pinctrl@e020/gph2: Missing interrupt-controller or interrupt-map 
property

It's reguired by Samsung aries boards, an S5PV210 based
Samsung Galaxy S (i9000) and Galaxy S 4G phones, which are added in next 
patches.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/boot/dts/s5pv210-pinctrl.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/s5pv210-pinctrl.dtsi 
b/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
index 3a79feab11c3..7f0c9d447871 100644
--- a/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
+++ b/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
@@ -258,6 +258,8 @@
gph2: gph2 {
gpio-controller;
#gpio-cells = <2>;
+
+   interrupt-controller;
#interrupt-cells = <2>;
};
 
-- 
2.7.4



Re: [PATCH v2 02/10] ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones

2018-06-28 Thread Paweł Chmiel
On Thursday, June 28, 2018 9:48:48 AM CEST Krzysztof Kozlowski wrote:
> On 28 June 2018 at 09:41, Krzysztof Kozlowski  wrote:
> > On 27 June 2018 at 19:12, Paweł Chmiel  
> > wrote:
> >> This DTS file have initial support Samsung Aries based phones.
> >> Initial version have support for:
> >> - sdcard
> >> - internal memory (present only on non 4g variant)
> >> - max8998 pmic and rtc
> >> - max17040 fuel gauge
> >> - gpio keys
> >> - fimd (no panel driver yet)
> >> - usb (peripherial mode)
> >> - wifi
> >>
> >> Signed-off-by: Paweł Chmiel 
> >> ---
> >>
> >> Changes from v1:
> >>   - Removed duplicated and unneeded headers
> >>   - Corrected node names
> >>   - Added missing spaces
> >>   - Removed unneeded pinctrl and sorted entries
> >>   - Set correct interrupt type for max8998 pmic
> >>   - Add missing regulators
> >> ---
> >> ---
> >>  arch/arm/boot/dts/s5pv210-aries.dtsi | 423 
> >> +++
> >>  1 file changed, 423 insertions(+)
> >>  create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi
> >>
> >> diff --git a/arch/arm/boot/dts/s5pv210-aries.dtsi 
> >> b/arch/arm/boot/dts/s5pv210-aries.dtsi
> >> new file mode 100644
> >> index ..61b6cf76265f
> >> --- /dev/null
> >> +++ b/arch/arm/boot/dts/s5pv210-aries.dtsi
> >> @@ -0,0 +1,423 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/*
> >> + * Samsung's S5PV210 based Galaxy Aries board device tree source
> >> + */
> >> +
> >> +/dts-v1/;
> >> +#include 
> >> +#include 
> >> +#include "s5pv210.dtsi"
> >> +
> >> +/ {
> >> +   compatible = "samsung,aries", "samsung,s5pv210";
> >> +
> >> +   aliases {
> >> +   i2c6 = &i2c_pmic;
> >> +   i2c9 = &i2c_fuel;
> >> +   };
> >> +
> >> +   memory@3000 {
> >> +   device_type = "memory";
> >> +   reg = <0x3000 0x0500
> >> +   0x4000 0x1000
> >> +   0x5000 0x0800>;
> >> +   };
> >> +
> >> +   wifi_pwrseq: wifi-pwrseq {
> >> +   compatible = "mmc-pwrseq-simple";
> >> +   reset-gpios = <&gpg1 2 GPIO_ACTIVE_LOW>;
> >> +   pinctrl-names = "default";
> >> +   pinctrl-0 = <&wlan_gpio_rst>;
> >> +   post-power-on-delay-ms = <500>;
> >> +   power-off-delay-us = <500>;
> >> +   };
> >> +
> >> +   i2c_pmic: i2c-gpio-0 {
> >> +   compatible = "i2c-gpio";
> >> +   sda-gpios = <&gpj4 0 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
> >> +   scl-gpios = <&gpj4 3 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
> >> +   i2c-gpio,delay-us = <2>;
> >> +   #address-cells = <1>;
> >> +   #size-cells = <0>;
> >> +
> >> +   pmic@66 {
> >> +   compatible = "maxim,max8998";
> >> +   reg = <0x66>;
> >> +   interrupt-parent = <&gph0>;
> >> +   interrupts = <7 IRQ_TYPE_EDGE_FALLING>;
> >> +
> >> +   max8998,pmic-buck1-default-dvs-idx = <1>;
> >> +   max8998,pmic-buck1-dvs-gpios = <&gph0 3 
> >> GPIO_ACTIVE_HIGH>,
> >> +   <&gph0 4 
> >> GPIO_ACTIVE_HIGH>;
> >> +   max8998,pmic-buck1-dvs-voltage = <1275000>, 
> >> <120>,
> >> +   <105>, 
> >> <95>;
> >> +
> >> +   max8998,pmic-buck2-default-dvs-idx = <0>;
> >> +   max8998,pmic-buck2-dvs-gpio = <&gph0 5 
> >> GPIO_ACTIVE_HIGH>;
> >> +   max8998,pmic-buck2-dvs-voltage = <110>, 
> >> <100>;
> >> +
> >> +   regulators {
> >> + 

[PATCH v3 3/9] ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone

2018-07-06 Thread Paweł Chmiel
This DTS file have initial support Samsung Galaxy S phone,
also known as i9000.
It belongs to Samsung Aries devices family.
Initial version have support for:
- sdcard
- internal memory
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Paweł Chmiel 

--
Changes from v1:
  - Added missing commit msg
  - Removed duplicated and unneeded headers
  - Added stdout-path
  - Added information why we hardcode bootargs
---
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/s5pv210-galaxys.dts | 77 +++
 2 files changed, 78 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 7e2424957809..522ebdca1d3d 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-smdk6410.dtb
 dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
+   s5pv210-galaxys.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
s5pv210-smdkv210.dtb \
diff --git a/arch/arm/boot/dts/s5pv210-galaxys.dts 
b/arch/arm/boot/dts/s5pv210-galaxys.dts
new file mode 100644
index ..842276749717
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-galaxys.dts
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210-aries.dtsi"
+
+/ {
+   model = "Samsung Galaxy S1 (GT-I9000) based on S5PV210";
+   compatible = "samsung,galaxys", "samsung,aries", "samsung,s5pv210";
+
+   chosen {
+   stdout-path = &uart2;
+   /*
+* It's hard to change those parameters in stock bootloader,
+* since it requires special hardware/cable.
+* Let's hardocde bootargs for now, till u-boot port is 
finished,
+* with which it should be easier.
+*/
+   bootargs = "root=/dev/mmcblk2p1 rw rootwait ignore_loglevel 
earlyprintk";
+   };
+
+   nand_pwrseq: nand-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpj2 7 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&massmemory_en>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   power {
+   label = "power";
+   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+
+   vol-down {
+   label = "volume_down";
+   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   vol-up {
+   label = "volume_up";
+   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   home {
+   label = "home";
+   gpios = <&gph3 5 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+   };
+};
+
+&pinctrl0 {
+   massmemory_en: massmemory-en {
+   samsung,pins = "gpj2-7";
+   samsung,pin-function = ;
+   samsung,pin-pud = ;
+   samsung,pin-drv = ;
+   };
+};
+
+&sdhci0 {
+   bus-width = <4>;
+   non-removable;
+   mmc-pwrseq = <&nand_pwrseq>;
+   pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4>;
+   pinctrl-names = "default";
+   status = "okay";
+};
-- 
2.7.4



[PATCH v3 9/9] ARM: s5pv210_defconfig: Enable options needed to boot typical Linux distro

2018-07-06 Thread Paweł Chmiel
This commit enables few options which are required to boot
typical Linux distro. It was tested by booting ArchLinux ARM
from sdcard.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/configs/s5pv210_defconfig | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index f719e7f9a655..a077597369f1 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -1,5 +1,7 @@
+CONFIG_SYSVIPC=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
+CONFIG_CGROUPS=y
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_SYSFS_DEPRECATED_V2=y
 CONFIG_BLK_DEV_INITRD=y
@@ -18,8 +20,18 @@ CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 
initrd=0x2080,8M console=ttyS
 CONFIG_VFP=y
 CONFIG_NEON=y
 CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
 CONFIG_CFG80211=m
+CONFIG_MAC80211=m
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
@@ -63,6 +75,8 @@ CONFIG_RTC_DRV_MAX8998=m
 CONFIG_PHY_SAMSUNG_USB2=m
 CONFIG_PHY_S5PV210_USB2=y
 CONFIG_EXT2_FS=y
+CONFIG_EXT4_FS=y
+CONFIG_AUTOFS4_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
 CONFIG_TMPFS=y
@@ -72,6 +86,7 @@ CONFIG_ROMFS_FS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_UTF8=y
 CONFIG_DEBUG_INFO=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_KERNEL=y
-- 
2.7.4



[PATCH v3 0/9] Initial support for Samsung Galaxy S and Galaxy S 4G

2018-07-06 Thread Paweł Chmiel
This patch series adds support for Samsung Galaxy S and Galaxy S 4G.
Both are commercial phone based on Aries family.

Changes from v2:
  - Restored pinctrl nodes order
  - Correct order of nodes in aries dtsi file
  - Added Reviewed-by to one of patches
  - Added Acked-by to one of patches
  - Squashed two patches updating samsung-boards documentation 

Changes from v1:
  - Removed duplicated and unneeded headers
  - Corrected node names
  - Formatting fixes
  - Removed unneeded pinctrl and sorted entries
  - Set correct interrupt type for max8998 pmic
  - Add missing regulators
  - Added missing commit msg
  - Added stdout-path
  - Added information why we hardcode bootargs
  - Added new patch which adds information, that there are samsung boards,
not using exynos bases soc.
  - Split patch updating s5pv210_defconfig into three parts.
First is result of make savedefconfig, second adds drivers required
by both devices and last adds some options, which are usefull in booting
typical Linux distribution.

Jonathan Bakker (2):
  ARM: dts: s5pv210: Add initial DTS for SGH-T959P phone
  dt-bindings: samsung: Document bindings for SGH-T959P board

Paweł Chmiel (7):
  ARM: dts: s5pv210: Add missing interrupt-controller property to gph2
  ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones
  ARM: dts: s5pv210: Add initial DTS for Samsung Galaxy S phone
  dt-bindings: samsung: Document bindings for Samsung aries boards
  ARM: s5pv210_defconfig: Run make savedefconfig
  ARM: s5pv210_defconfig: Enable drivers for Samsung Aries based phones
  ARM: s5pv210_defconfig: Enable options needed to boot typical Linux
distro

 .../bindings/arm/samsung/samsung-boards.txt|   5 +-
 arch/arm/boot/dts/Makefile |   2 +
 arch/arm/boot/dts/s5pv210-aries.dtsi   | 423 +
 arch/arm/boot/dts/s5pv210-fascinate4g.dts  |  45 +++
 arch/arm/boot/dts/s5pv210-galaxys.dts  |  77 
 arch/arm/boot/dts/s5pv210-pinctrl.dtsi |   2 +
 arch/arm/configs/s5pv210_defconfig |  49 ++-
 7 files changed, 599 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi
 create mode 100644 arch/arm/boot/dts/s5pv210-fascinate4g.dts
 create mode 100644 arch/arm/boot/dts/s5pv210-galaxys.dts

-- 
2.7.4



[PATCH v3 8/9] ARM: s5pv210_defconfig: Enable drivers for Samsung Aries based phones

2018-07-06 Thread Paweł Chmiel
Enable config options required for Samsung Aries based phones.
ARM_APPENDED_DTB is also needed, because stock bootloader
does not support loading dtb files.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/configs/s5pv210_defconfig | 33 +++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index 9c862d366fb3..f719e7f9a655 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -13,9 +13,12 @@ CONFIG_SOLARIS_X86_PARTITION=y
 CONFIG_ARCH_S5PV210=y
 CONFIG_VMSPLIT_2G=y
 CONFIG_PREEMPT=y
+CONFIG_ARM_APPENDED_DTB=y
 CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x2080,8M 
console=ttySAC1,115200 init=/linuxrc"
 CONFIG_VFP=y
 CONFIG_NEON=y
+CONFIG_NET=y
+CONFIG_CFG80211=m
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
@@ -23,16 +26,42 @@ CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_SG=y
+CONFIG_NETDEVICES=y
+CONFIG_BRCMFMAC=m
 CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_KEYBOARD is not set
+CONFIG_KEYBOARD_GPIO=y
 # CONFIG_INPUT_MOUSE is not set
 CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_SAMSUNG=y
 CONFIG_SERIAL_SAMSUNG_CONSOLE=y
 CONFIG_HW_RANDOM=y
+CONFIG_I2C_GPIO=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_BATTERY_MAX17040=y
 # CONFIG_HWMON is not set
-# CONFIG_USB_SUPPORT is not set
+CONFIG_MFD_MAX8998=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_MAX8998=y
+CONFIG_DRM=y
+CONFIG_DRM_EXYNOS=y
+CONFIG_DRM_EXYNOS_FIMD=y
+CONFIG_DRM_EXYNOS_DPI=y
+CONFIG_USB=y
+CONFIG_USB_OTG=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_EXYNOS=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_EXYNOS=y
+CONFIG_USB_DWC2=y
+CONFIG_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_S3C=y
+CONFIG_MMC_SDHCI_S3C_DMA=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_MAX8998=m
+CONFIG_PHY_SAMSUNG_USB2=m
+CONFIG_PHY_S5PV210_USB2=y
 CONFIG_EXT2_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
-- 
2.7.4



[PATCH v3 7/9] ARM: s5pv210_defconfig: Run make savedefconfig

2018-07-06 Thread Paweł Chmiel
This is result of running savedefconfig.
It's preparation for adding support for Samsung Aries devices.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/configs/s5pv210_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index 09b5a7386414..9c862d366fb3 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -13,7 +13,6 @@ CONFIG_SOLARIS_X86_PARTITION=y
 CONFIG_ARCH_S5PV210=y
 CONFIG_VMSPLIT_2G=y
 CONFIG_PREEMPT=y
-CONFIG_AEABI=y
 CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x2080,8M 
console=ttySAC1,115200 init=/linuxrc"
 CONFIG_VFP=y
 CONFIG_NEON=y
-- 
2.7.4



[PATCH v3 4/9] ARM: dts: s5pv210: Add initial DTS for SGH-T959P phone

2018-07-06 Thread Paweł Chmiel
From: Jonathan Bakker 

This DTS file have initial support Samsung SGH-T959P phone,
also known as Samsung Galaxy S 4G or fascinate4g.
It belongs to Samsung Aries devices family.
Initial version have support for:
- sdcard
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---

Changes from v1:
  - Added missing commit msg
  - Removed duplicated and unneeded headers
  - Added stdout-path
  - Added information why we hardcode bootargs
---
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/s5pv210-fascinate4g.dts | 45 +++
 2 files changed, 46 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-fascinate4g.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 522ebdca1d3d..d00e995875bb 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -846,6 +846,7 @@ dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-smdk6410.dtb
 dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
+   s5pv210-fascinate4g.dtb \
s5pv210-galaxys.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
diff --git a/arch/arm/boot/dts/s5pv210-fascinate4g.dts 
b/arch/arm/boot/dts/s5pv210-fascinate4g.dts
new file mode 100644
index ..ccf761b1babf
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-fascinate4g.dts
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210-aries.dtsi"
+
+/ {
+   model = "Samsung Galaxy S Fascinate 4G (SGH-T959P) based on S5PV210";
+   compatible = "samsung,fascinate4g", "samsung,aries", "samsung,s5pv210";
+
+   chosen {
+   stdout-path = &uart2;
+   /*
+* It's hard to change those parameters in stock bootloader,
+* since it requires special hardware/cable.
+* Let's hardocde bootargs for now, till u-boot port is 
finished,
+* with which it should be easier.
+*/
+   bootargs = "root=/dev/mmcblk1p1 rw rootwait ignore_loglevel 
earlyprintk";
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   power {
+   label = "power";
+   gpios = <&gph2 6 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   wakeup-source;
+   };
+
+   vol-down {
+   label = "volume_down";
+   gpios = <&gph3 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   vol-up {
+   label = "volume_up";
+   gpios = <&gph3 1 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+};
-- 
2.7.4



[PATCH v3 1/9] ARM: dts: s5pv210: Add missing interrupt-controller property to gph2

2018-07-06 Thread Paweł Chmiel
Adds missing interrupt-controller property to gph2 block,
to silence following warnings during build
  /soc/pinctrl@e020/gph2: Missing interrupt-controller or interrupt-map 
property

It's reguired by Samsung aries boards, an S5PV210 based
Samsung Galaxy S (i9000) and Galaxy S 4G phones, which are added in next 
patches.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/boot/dts/s5pv210-pinctrl.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/s5pv210-pinctrl.dtsi 
b/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
index 3a79feab11c3..7f0c9d447871 100644
--- a/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
+++ b/arch/arm/boot/dts/s5pv210-pinctrl.dtsi
@@ -258,6 +258,8 @@
gph2: gph2 {
gpio-controller;
#gpio-cells = <2>;
+
+   interrupt-controller;
#interrupt-cells = <2>;
};
 
-- 
2.7.4



[PATCH v3 6/9] dt-bindings: samsung: Document bindings for SGH-T959P board

2018-07-06 Thread Paweł Chmiel
From: Jonathan Bakker 

Document the binding for Samsung Galaxy S Fascinate 4G (SGH-T959P).

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
Acked-by: Rob Herring 
--
Changes from v2:
  - Added Acked-by

Changes from v1:
  - Added missing commit msg.
--
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index 3fa287a86300..37e96e48c48c 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -3,6 +3,7 @@
 Required root node properties:
 - compatible = should be one or more of the following.
- "samsung,aries"   - for S5PV210-based Samsung Aries board.
+   - "samsung,fascinate4g" - for S5PV210-based Samsung Galaxy S Fascinate 
4G (SGH-T959P) board.
- "samsung,galaxys" - for S5PV210-based Samsung Galaxy S (i9000)  
board.
- "samsung,artik5"  - for Exynos3250-based Samsung ARTIK5 module.
- "samsung,artik5-eval" - for Exynos3250-based Samsung ARTIK5 eval 
board.
-- 
2.7.4



[PATCH v3 5/9] dt-bindings: samsung: Document bindings for Samsung aries boards

2018-07-06 Thread Paweł Chmiel
Document the binding for Samsung Galaxy S (i9000) phone
and whole Samsung Aries devices family (based on S5PV210).

Also because this is first not Exynos-based devices, document this information
at beginning of file.

Signed-off-by: Paweł Chmiel 
Reviewed-by: Rob Herring 
--
Changes from v2:
  - Squashed with patch which was documenting existence
of non Exynos-based boards
  - Added reviewed-by

Changes from v1:
  - Added missing commit msg.
--
---
 Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt 
b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index 14510b215480..3fa287a86300 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -1,7 +1,9 @@
-* Samsung's Exynos SoC based boards
+* Samsung's Exynos and S5P SoC based boards
 
 Required root node properties:
 - compatible = should be one or more of the following.
+   - "samsung,aries"   - for S5PV210-based Samsung Aries board.
+   - "samsung,galaxys" - for S5PV210-based Samsung Galaxy S (i9000)  
board.
- "samsung,artik5"  - for Exynos3250-based Samsung ARTIK5 module.
- "samsung,artik5-eval" - for Exynos3250-based Samsung ARTIK5 eval 
board.
- "samsung,monk"- for Exynos3250-based Samsung Simband board.
-- 
2.7.4



[PATCH v3 2/9] ARM: dts: s5pv210: Add initial DTS for Samsung Aries based phones

2018-07-06 Thread Paweł Chmiel
This DTS file have initial support Samsung Aries based phones.
Initial version have support for:
- sdcard
- internal memory (present only on non 4g variant)
- max8998 pmic and rtc
- max17040 fuel gauge
- gpio keys
- fimd (no panel driver yet)
- usb (peripherial mode)
- wifi

Signed-off-by: Paweł Chmiel 
---
Changes from v2:
  - Restored pinctrl nodes order
  - Correct order of nodes

Changes from v1:
  - Removed duplicated and unneeded headers
  - Corrected node names
  - Added missing spaces
  - Removed unneeded pinctrl and sorted entries
  - Set correct interrupt type for max8998 pmic
  - Add missing regulators
---
---
 arch/arm/boot/dts/s5pv210-aries.dtsi | 423 +++
 1 file changed, 423 insertions(+)
 create mode 100644 arch/arm/boot/dts/s5pv210-aries.dtsi

diff --git a/arch/arm/boot/dts/s5pv210-aries.dtsi 
b/arch/arm/boot/dts/s5pv210-aries.dtsi
new file mode 100644
index ..0dfba52e1cdb
--- /dev/null
+++ b/arch/arm/boot/dts/s5pv210-aries.dtsi
@@ -0,0 +1,423 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Samsung's S5PV210 based Galaxy Aries board device tree source
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include "s5pv210.dtsi"
+
+/ {
+   compatible = "samsung,aries", "samsung,s5pv210";
+
+   aliases {
+   i2c6 = &i2c_pmic;
+   i2c9 = &i2c_fuel;
+   };
+
+   memory@3000 {
+   device_type = "memory";
+   reg = <0x3000 0x0500
+   0x4000 0x1000
+   0x5000 0x0800>;
+   };
+
+   wifi_pwrseq: wifi-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpg1 2 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&wlan_gpio_rst>;
+   post-power-on-delay-ms = <500>;
+   power-off-delay-us = <500>;
+   };
+
+   i2c_pmic: i2c-gpio-0 {
+   compatible = "i2c-gpio";
+   sda-gpios = <&gpj4 0 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+   scl-gpios = <&gpj4 3 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+   i2c-gpio,delay-us = <2>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   pmic@66 {
+   compatible = "maxim,max8998";
+   reg = <0x66>;
+   interrupt-parent = <&gph0>;
+   interrupts = <7 IRQ_TYPE_EDGE_FALLING>;
+
+   max8998,pmic-buck1-default-dvs-idx = <1>;
+   max8998,pmic-buck1-dvs-gpios = <&gph0 3 
GPIO_ACTIVE_HIGH>,
+   <&gph0 4 
GPIO_ACTIVE_HIGH>;
+   max8998,pmic-buck1-dvs-voltage = <1275000>, <120>,
+   <105>, <95>;
+
+   max8998,pmic-buck2-default-dvs-idx = <0>;
+   max8998,pmic-buck2-dvs-gpio = <&gph0 5 
GPIO_ACTIVE_HIGH>;
+   max8998,pmic-buck2-dvs-voltage = <110>, <100>;
+
+   regulators {
+   ldo2_reg: LDO2 {
+   regulator-name = "VALIVE_1.2V";
+   regulator-min-microvolt = <120>;
+   regulator-max-microvolt = <120>;
+   regulator-always-on;
+
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   };
+   };
+
+   ldo3_reg: LDO3 {
+   regulator-name = "VUSB_1.1V";
+   regulator-min-microvolt = <110>;
+   regulator-max-microvolt = <110>;
+
+   regulator-state-mem {
+   regulator-off-in-suspend;
+   };
+   };
+
+   ldo4_reg: LDO4 {
+   regulator-name = "VADC_3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+
+   regulator-state-mem {
+   regulator-off-in-su

[PATCH v3] Bluetooth: hci_bcm: Handle specific unknown packets after firmware loading

2018-12-19 Thread Paweł Chmiel
From: Jonathan Bakker 

The Broadcom controller on aries S5PV210 boards sends out a couple of
unknown packets after the firmware is loaded.  This will cause
logging of errors such as:
Bluetooth: hci0: Frame reassembly failed (-84)

This is probably also the case with other boards, as there are related
Android userspace patches for custom ROMs such as
https://review.lineageos.org/#/c/LineageOS/android_system_bt/+/142721/
Since this appears to be intended behaviour, treated them as diagnostic
packets.

Note that this is another variant of commit 01d5e44ace8a
("Bluetooth: hci_bcm: Handle empty packet after firmware loading")

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 

---
Changes from v2:
   - Rebased against latest bluetooth-next tree

Changes from v1:
   - Rename UNKNOWN to TYPE49
   - Rename UNKNOWN2 to TYPE52
---
 drivers/bluetooth/hci_bcm.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index a5cb580a07de..ddbe518c3e5b 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -52,6 +52,12 @@
 #define BCM_LM_DIAG_PKT 0x07
 #define BCM_LM_DIAG_SIZE 63
 
+#define BCM_TYPE49_PKT 0x31
+#define BCM_TYPE49_SIZE 0
+
+#define BCM_TYPE52_PKT 0x34
+#define BCM_TYPE52_SIZE 0
+
 #define BCM_AUTOSUSPEND_DELAY  5000 /* default autosleep delay */
 
 #define BCM_NUM_SUPPLIES 2
@@ -595,12 +601,28 @@ static int bcm_setup(struct hci_uart *hu)
.lsize = 0, \
.maxlen = BCM_NULL_SIZE
 
+#define BCM_RECV_TYPE49 \
+   .type = BCM_TYPE49_PKT, \
+   .hlen = BCM_TYPE49_SIZE, \
+   .loff = 0, \
+   .lsize = 0, \
+   .maxlen = BCM_TYPE49_SIZE
+
+#define BCM_RECV_TYPE52 \
+   .type = BCM_TYPE52_PKT, \
+   .hlen = BCM_TYPE52_SIZE, \
+   .loff = 0, \
+   .lsize = 0, \
+   .maxlen = BCM_TYPE52_SIZE
+
 static const struct h4_recv_pkt bcm_recv_pkts[] = {
{ H4_RECV_ACL,  .recv = hci_recv_frame },
{ H4_RECV_SCO,  .recv = hci_recv_frame },
{ H4_RECV_EVENT,.recv = hci_recv_frame },
{ BCM_RECV_LM_DIAG, .recv = hci_recv_diag  },
{ BCM_RECV_NULL,.recv = hci_recv_diag  },
+   { BCM_RECV_TYPE49,  .recv = hci_recv_diag  },
+   { BCM_RECV_TYPE52,  .recv = hci_recv_diag  },
 };
 
 static int bcm_recv(struct hci_uart *hu, const void *data, int count)
-- 
2.17.1



[PATCH v2] Bluetooth: btbcm: Add entry for BCM4329B1 UART bluetooth

2018-12-19 Thread Paweł Chmiel
This patch adds the device ID for the BCM 4329 combo module used
in the Samsung Aries based phones (Galaxy S and it's variants).

```
[   11.508980] Bluetooth: hci0: BCM: chip id 41
[   11.518975] Bluetooth: hci0: BCM: features 0x04
[   11.550132] Bluetooth: hci0: BCM4329B1
[   11.557046] Bluetooth: hci0: BCM4329B1 (002.002.023) build 
[   13.737071] Bluetooth: hci0: BCM4329B1 (002.002.023) build 0744
```

Output from hciconfig

```
hci0:   Type: Primary  Bus: UART
BD Address: 43:29:B1:55:00:00  ACL MTU: 1021:6  SCO MTU: 64:1
UP RUNNING
RX bytes:1675 acl:0 sco:0 events:145 errors:0
TX bytes:20426 acl:0 sco:0 commands:146 errors:0
Features: 0xbf 0xfe 0x8f 0xfe 0x9b 0xff 0x79 0x83
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: 'aries'
Class: 0x00
Service Classes: Unspecified
Device Class: Miscellaneous,
HCI Version: 2.1 (0x4)  Revision: 0x2e8
LMP Version: 2.1 (0x4)  Subversion: 0x4217
Manufacturer: Broadcom Corporation (15)
```

Signed-off-by: Paweł Chmiel 
---
Changes from v1:
   - Rebased against latest bluetooth-next tree
---
 drivers/bluetooth/btbcm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 08e1f3dd4e03..d5d6e6e5da3b 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -341,6 +341,7 @@ static const struct bcm_subver_table 
bcm_uart_subver_table[] = {
{ 0x6119, "BCM4345C0"   },  /* 003.001.025 */
{ 0x230f, "BCM4356A2"   },  /* 001.003.015 */
{ 0x220e, "BCM20702A1"  },  /* 001.002.014 */
+   { 0x4217, "BCM4329B1"   },  /* 002.002.023 */
{ }
 };
 
-- 
2.17.1



Re: [PATCH v2] Bluetooth: hci_bcm: Handle specific unknown packets after firmware loading

2018-12-19 Thread Paweł Chmiel
Dnia środa, 19 grudnia 2018 00:49:49 CET Marcel Holtmann pisze:
> Hi Pawel,
> 
> > The Broadcom controller on aries S5PV210 boards sends out a couple of
> > unknown packets after the firmware is loaded.  This will cause
> > logging of errors such as:
> > Bluetooth: hci0: Frame reassembly failed (-84)
> > 
> > This is probably also the case with other boards, as there are related
> > Android userspace patches for custom ROMs such as
> > https://review.lineageos.org/#/c/LineageOS/android_system_bt/+/142721/
> > Since this appears to be intended behaviour, treated them as diagnostic
> > packets.
> > 
> > Note that this is another variant of commit 01d5e44ace8a
> > ("Bluetooth: hci_bcm: Handle empty packet after firmware loading")
> > 
> > Signed-off-by: Jonathan Bakker 
> > Signed-off-by: Paweł Chmiel 
> > 
> > ---
> > Changes from v1:
> > - Rename UNKNOWN to TYPE49
> > - Rename UNKNOWN2 to TYPE52
> > ---
> > drivers/bluetooth/hci_bcm.c | 22 ++
> > 1 file changed, 22 insertions(+)
> 
> can you update this patch against latest bluetooth-next tree since it no 
> longer applies cleanly.
I've send new version of both patches (this and Bluetooth: hci_bcm: Handle 
specific unknown packets after firmware loading), rebased against latest 
bluetooth-next.
> 
> Regards
> 
> Marcel
> 






[PATCH 1/3] drm/exynos: rotator: Add support for s5pv210

2018-12-19 Thread Paweł Chmiel
This commit adds support for s5pv210.
Currently only NV12 and XRGB formats are supported.
It was tested by using tool from
https://www.spinics.net/lists/linux-samsung-soc/msg60498.html

Signed-off-by: Paweł Chmiel 
---
 drivers/gpu/drm/exynos/exynos_drm_rotator.c | 23 +
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c 
b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
index a820a68429b9..a822d340ccf6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -357,6 +357,11 @@ static int rotator_runtime_resume(struct device *dev)
 }
 #endif
 
+static const struct drm_exynos_ipp_limit rotator_s5pv210_rbg888_limits[] = {
+   { IPP_SIZE_LIMIT(BUFFER, .h = { 8, SZ_16K }, .v = { 8, SZ_16K }) },
+   { IPP_SIZE_LIMIT(AREA, .h.align = 2, .v.align = 2) },
+};
+
 static const struct drm_exynos_ipp_limit rotator_4210_rbg888_limits[] = {
{ IPP_SIZE_LIMIT(BUFFER, .h = { 8, SZ_16K }, .v = { 8, SZ_16K }) },
{ IPP_SIZE_LIMIT(AREA, .h.align = 4, .v.align = 4) },
@@ -372,6 +377,11 @@ static const struct drm_exynos_ipp_limit 
rotator_5250_rbg888_limits[] = {
{ IPP_SIZE_LIMIT(AREA, .h.align = 2, .v.align = 2) },
 };
 
+static const struct drm_exynos_ipp_limit rotator_s5pv210_yuv_limits[] = {
+   { IPP_SIZE_LIMIT(BUFFER, .h = { 32, SZ_64K }, .v = { 32, SZ_64K }) },
+   { IPP_SIZE_LIMIT(AREA, .h.align = 8, .v.align = 8) },
+};
+
 static const struct drm_exynos_ipp_limit rotator_4210_yuv_limits[] = {
{ IPP_SIZE_LIMIT(BUFFER, .h = { 32, SZ_64K }, .v = { 32, SZ_64K }) },
{ IPP_SIZE_LIMIT(AREA, .h.align = 8, .v.align = 8) },
@@ -382,6 +392,11 @@ static const struct drm_exynos_ipp_limit 
rotator_4412_yuv_limits[] = {
{ IPP_SIZE_LIMIT(AREA, .h.align = 8, .v.align = 8) },
 };
 
+static const struct exynos_drm_ipp_formats rotator_s5pv210_formats[] = {
+   { IPP_SRCDST_FORMAT(XRGB, rotator_s5pv210_rbg888_limits) },
+   { IPP_SRCDST_FORMAT(NV12, rotator_s5pv210_yuv_limits) },
+};
+
 static const struct exynos_drm_ipp_formats rotator_4210_formats[] = {
{ IPP_SRCDST_FORMAT(XRGB, rotator_4210_rbg888_limits) },
{ IPP_SRCDST_FORMAT(NV12, rotator_4210_yuv_limits) },
@@ -397,6 +412,11 @@ static const struct exynos_drm_ipp_formats 
rotator_5250_formats[] = {
{ IPP_SRCDST_FORMAT(NV12, rotator_4412_yuv_limits) },
 };
 
+static const struct rot_variant rotator_s5pv210_data = {
+   .formats = rotator_s5pv210_formats,
+   .num_formats = ARRAY_SIZE(rotator_s5pv210_formats),
+};
+
 static const struct rot_variant rotator_4210_data = {
.formats = rotator_4210_formats,
.num_formats = ARRAY_SIZE(rotator_4210_formats),
@@ -414,6 +434,9 @@ static const struct rot_variant rotator_5250_data = {
 
 static const struct of_device_id exynos_rotator_match[] = {
{
+   .compatible = "samsung,s5pv210-rotator",
+   .data = &rotator_s5pv210_data,
+   }, {
.compatible = "samsung,exynos4210-rotator",
.data = &rotator_4210_data,
}, {
-- 
2.17.1



[PATCH 0/3] drm/exynos: rotator: Add support for s5pv210

2018-12-19 Thread Paweł Chmiel
This patchset adds support for s5pv210 soc, into 
Samsung DRM Rotator driver. Currently only NV12 and XRGB formats
 are supported.

It was tested by using simple tool from 
https://www.spinics.net/lists/linux-samsung-soc/msg60498.html

Paweł Chmiel (3):
  drm/exynos: rotator: Add support for s5pv210
  dt-bindings: gpu: samsung-rotator: Document s5pv210 support
  ARM: dts: s5pv210: Add node for exynos-rotator

 .../bindings/gpu/samsung-rotator.txt  |  1 +
 arch/arm/boot/dts/s5pv210.dtsi|  9 
 drivers/gpu/drm/exynos/exynos_drm_rotator.c   | 23 +++
 3 files changed, 33 insertions(+)

-- 
2.17.1



[PATCH 3/3] ARM: dts: s5pv210: Add node for exynos-rotator

2018-12-19 Thread Paweł Chmiel
This commit adds node for Exynos Rorator device,
so it can be used on all s5pv210 based devices.

Signed-off-by: Paweł Chmiel 
---
 arch/arm/boot/dts/s5pv210.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/s5pv210.dtsi b/arch/arm/boot/dts/s5pv210.dtsi
index 75f454a210d6..a5463003c7f6 100644
--- a/arch/arm/boot/dts/s5pv210.dtsi
+++ b/arch/arm/boot/dts/s5pv210.dtsi
@@ -542,6 +542,15 @@
#dma-requests = <1>;
};
 
+   rotator: rotator@fa30 {
+   compatible = "samsung,s5pv210-rotator";
+   reg = <0xfa30 0x1000>;
+   interrupt-parent = <&vic2>;
+   interrupts = <4>;
+   clocks = <&clocks CLK_ROTATOR>;
+   clock-names = "rotator";
+   };
+
i2c1: i2c@fab0 {
compatible = "samsung,s3c2440-i2c";
reg = <0xfab0 0x1000>;
-- 
2.17.1



[PATCH 2/3] dt-bindings: gpu: samsung-rotator: Document s5pv210 support

2018-12-19 Thread Paweł Chmiel
This commit documents new compatible for s5pv210 soc,
which will be also supported by this driver.

Signed-off-by: Paweł Chmiel 
---
 Documentation/devicetree/bindings/gpu/samsung-rotator.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/gpu/samsung-rotator.txt 
b/Documentation/devicetree/bindings/gpu/samsung-rotator.txt
index 82cd1ed0be93..78658dec6941 100644
--- a/Documentation/devicetree/bindings/gpu/samsung-rotator.txt
+++ b/Documentation/devicetree/bindings/gpu/samsung-rotator.txt
@@ -5,6 +5,7 @@ Required properties:
(a) "samsung,exynos4210-rotator" for Rotator IP in Exynos4210
(b) "samsung,exynos4212-rotator" for Rotator IP in Exynos4212/4412
(c) "samsung,exynos5250-rotator" for Rotator IP in Exynos5250
+   (d) "samsung,s5pv210-rotator" for Rotator IP in S5PV210
 
   - reg : Physical base address of the IP registers and length of memory
  mapped region.
-- 
2.17.1



Re: [PATCH v4 1/3] Input: atmel_mxt_ts: Add support for optional regulators

2018-12-14 Thread Paweł Chmiel
Dnia niedziela, 9 grudnia 2018 05:26:12 CET Dmitry Torokhov pisze:
> On Fri, Dec 07, 2018 at 03:28:55PM +0100, Paweł Chmiel wrote:
> > This patch adds optional regulators, which can be used to power
> > up touchscreen. After enabling regulators, we need to wait 150msec.
> > This value is taken from official driver.
> > 
> > It was tested on Samsung Galaxy i9000 (based on Samsung S5PV210 SOC).
> > 
> > Signed-off-by: Paweł Chmiel 
> > ---
> > Changes from v3:
> >   - Fix checkpatch issues
> >   - Drop sentence punctuation from subject of one of patches
> > 
> > Changes from v2:
> >   - Move code enabling regulators into separate method,
> > to make code more readable.
> > 
> > Changes from v1:
> >   - Enable regulators only if reset_gpio is present.
> >   - Switch from devm_regulator_get_optional to devm_regulator_get
> > ---
> >  drivers/input/touchscreen/atmel_mxt_ts.c | 65 +---
> >  1 file changed, 59 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
> > b/drivers/input/touchscreen/atmel_mxt_ts.c
> > index d3aacd534e9c..1dc8ad0da5af 100644
> > --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -194,10 +195,10 @@ enum t100_type {
> >  
> >  /* Delay times */
> >  #define MXT_BACKUP_TIME50  /* msec */
> > -#define MXT_RESET_GPIO_TIME20  /* msec */
> >  #define MXT_RESET_INVALID_CHG  100 /* msec */
> >  #define MXT_RESET_TIME 200 /* msec */
> >  #define MXT_RESET_TIMEOUT  3000/* msec */
> > +#define MXT_REGULATOR_DELAY150 /* msec */
> >  #define MXT_CRC_TIMEOUT1000/* msec */
> >  #define MXT_FW_RESET_TIME  3000/* msec */
> >  #define MXT_FW_CHG_TIMEOUT 300 /* msec */
> > @@ -323,6 +324,8 @@ struct mxt_data {
> > struct t7_config t7_cfg;
> > struct mxt_dbg dbg;
> > struct gpio_desc *reset_gpio;
> > +   struct regulator *vdd_reg;
> > +   struct regulator *avdd_reg;
> >  
> > /* Cached parameters from object table */
> > u16 T5_address;
> > @@ -3038,6 +3041,38 @@ static const struct dmi_system_id 
> > chromebook_T9_suspend_dmi[] = {
> > { }
> >  };
> >  
> > +static int mxt_regulator_enable(struct mxt_data *data)
> > +{
> > +   int error;
> > +
> > +   if (data->reset_gpio) {
> > +   error = regulator_enable(data->vdd_reg);
> > +   if (error) {
> > +   dev_err(&data->client->dev,
> > +   "Failed to enable vdd regulator: %d\n", error);
> > +   return error;
> > +   }
> > +
> > +   error = regulator_enable(data->avdd_reg);
> > +   if (error) {
> > +   dev_err(&data->client->dev,
> > +   "Failed to enable avdd regulator: %d\n", error);
> 
> This leaves vdd regulator enabled.
Will be fixed in v5 version (will be today)
Thanks for review.
> 
> Thanks.
> 
> 






[PATCH v5 1/3] Input: atmel_mxt_ts: Add support for optional regulators

2018-12-14 Thread Paweł Chmiel
This patch adds optional regulators, which can be used to power
up touchscreen. After enabling regulators, we need to wait 150msec.
This value is taken from official driver.

It was tested on Samsung Galaxy i9000 (based on Samsung S5PV210 SOC).

Signed-off-by: Paweł Chmiel 
---
Changes from v4:
  - Add missing regulator_disable for vdd in case of error,
when enabling avdd regulator

Changes from v3:
  - Fix checkpatch issues
  - Drop sentence punctuation from patch subject

Changes from v2:
  - Move code enabling regulators into separate method,
to make code more readable.

Changes from v1:
  - Enable regulators only if reset_gpio is present.
  - Switch from devm_regulator_get_optional to devm_regulator_get
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 67 +---
 1 file changed, 61 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index d3aacd534e9c..55a107fc1b73 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -194,10 +195,10 @@ enum t100_type {
 
 /* Delay times */
 #define MXT_BACKUP_TIME50  /* msec */
-#define MXT_RESET_GPIO_TIME20  /* msec */
 #define MXT_RESET_INVALID_CHG  100 /* msec */
 #define MXT_RESET_TIME 200 /* msec */
 #define MXT_RESET_TIMEOUT  3000/* msec */
+#define MXT_REGULATOR_DELAY150 /* msec */
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
@@ -323,6 +324,8 @@ struct mxt_data {
struct t7_config t7_cfg;
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
+   struct regulator *vdd_reg;
+   struct regulator *avdd_reg;
 
/* Cached parameters from object table */
u16 T5_address;
@@ -3038,6 +3041,40 @@ static const struct dmi_system_id 
chromebook_T9_suspend_dmi[] = {
{ }
 };
 
+static int mxt_regulator_enable(struct mxt_data *data)
+{
+   int error;
+
+   if (data->reset_gpio) {
+   error = regulator_enable(data->vdd_reg);
+   if (error) {
+   dev_err(&data->client->dev,
+   "Failed to enable vdd regulator: %d\n", error);
+   return error;
+   }
+
+   error = regulator_enable(data->avdd_reg);
+   if (error) {
+   regulator_disable(data->vdd_reg);
+
+   dev_err(&data->client->dev,
+   "Failed to enable avdd regulator: %d\n", error);
+   return error;
+   }
+
+   /*
+* According to maXTouch power sequencing specification,
+* RESET line must be kept low until some time
+* after regulators come up to voltage
+*/
+   msleep(MXT_REGULATOR_DELAY);
+   gpiod_set_value(data->reset_gpio, 1);
+   msleep(MXT_RESET_INVALID_CHG);
+   }
+
+   return 0;
+}
+
 static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
struct mxt_data *data;
@@ -3098,6 +3135,22 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
return error;
}
 
+   data->vdd_reg = devm_regulator_get(&client->dev, "vdd");
+   if (IS_ERR(data->vdd_reg)) {
+   error = PTR_ERR(data->vdd_reg);
+   dev_err(&client->dev, "Failed to get vdd regulator: %d\n",
+   error);
+   return error;
+   }
+
+   data->avdd_reg = devm_regulator_get(&client->dev, "avdd");
+   if (IS_ERR(data->avdd_reg)) {
+   error = PTR_ERR(data->avdd_reg);
+   dev_err(&client->dev, "Failed to get avdd regulator: %d\n",
+   error);
+   return error;
+   }
+
error = devm_request_threaded_irq(&client->dev, client->irq,
  NULL, mxt_interrupt, IRQF_ONESHOT,
  client->name, data);
@@ -3108,11 +3161,9 @@ static int mxt_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
 
disable_irq(client->irq);
 
-   if (data->reset_gpio) {
-   msleep(MXT_RESET_GPIO_TIME);
-   gpiod_set_value(data->reset_gpio, 1);
-   msleep(MXT_RESET_INVALID_CHG);
-   }
+   error = mxt_regulator_enable(data);
+   if (error)
+   return error;
 
error = mxt_initialize(data);
if (error)
@@ -3138,6 +3189,10 @@ static i

[PATCH v5 0/3] Input: atmel_mxt_ts: Add support for optional regulators

2018-12-14 Thread Paweł Chmiel
This patch series adds optional regulator support to atmel_mxt_ts.
First patch adds regulators to driver.
Second patch ensures that device is ready for communication.
Third patch updates documentation.

Changes from v4:
  - Add missing regulator_disable for vdd in case of error,
when enabling avdd regulator

Changes from v3:
  - Checkpatch fixes
  - Drop punctuation from subject of one of patches

Changes from v2:
  - Add reviewed-by to one patch
  - Move code for enabling regulators into separate method,
to make code more readable.
  - Add wait code, to ensure that device is ready for communication.

Changes from v1:
  - Enable regulators only if reset_gpio is present.
  - Switch from devm_regulator_get_optional to devm_regulator_get.

Paweł Chmiel (3):
  Input: atmel_mxt_ts: Add support for  optional regulators
  Input: atmel_mxt_ts: Wait for device be ready for communication
  Input: atmel_mxt_ts: Document optional voltage regulators

 .../bindings/input/atmel,maxtouch.txt |  8 ++
 drivers/input/touchscreen/atmel_mxt_ts.c  | 78 +--
 2 files changed, 80 insertions(+), 6 deletions(-)

-- 
2.17.1



[PATCH v5 2/3] Input: atmel_mxt_ts: Wait for device be ready for communication

2018-12-14 Thread Paweł Chmiel
According to documentation, device isn't ready for communication,
until firmware asserts the CHG line. Add missing wait for this.

Signed-off-by: Paweł Chmiel 
---
Changes from v1:
  - Fix checkpatch issues
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index 55a107fc1b73..e8949c6ceafa 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -202,6 +202,7 @@ enum t100_type {
 #define MXT_CRC_TIMEOUT1000/* msec */
 #define MXT_FW_RESET_TIME  3000/* msec */
 #define MXT_FW_CHG_TIMEOUT 300 /* msec */
+#define MXT_POWERON_DELAY  150 /* msec */
 
 /* Command to unlock bootloader */
 #define MXT_UNLOCK_CMD_MSB 0xaa
@@ -3070,6 +3071,16 @@ static int mxt_regulator_enable(struct mxt_data *data)
msleep(MXT_REGULATOR_DELAY);
gpiod_set_value(data->reset_gpio, 1);
msleep(MXT_RESET_INVALID_CHG);
+
+retry_wait:
+   reinit_completion(&data->bl_completion);
+   data->in_bootloader = true;
+   error = mxt_wait_for_completion(data, &data->bl_completion,
+   MXT_POWERON_DELAY);
+   if (error == -EINTR)
+   goto retry_wait;
+
+   data->in_bootloader = false;
}
 
return 0;
-- 
2.17.1



[PATCH v5 3/3] Input: atmel_mxt_ts: Document optional voltage regulators

2018-12-14 Thread Paweł Chmiel
Document new optional voltage regulators, which can be used
to power down/up touchscreen.

Signed-off-by: Paweł Chmiel 
Reviewed-by: Rob Herring 
---
Changes from v1:
  - Added reviewed-by
---
 .../devicetree/bindings/input/atmel,maxtouch.txt  | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt 
b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
index c88919480d37..17930ecadad3 100644
--- a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
+++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
@@ -31,6 +31,12 @@ Optional properties for main touchpad device:
 
 - reset-gpios: GPIO specifier for the touchscreen's reset pin (active low)
 
+- avdd-supply: Analog power supply. It powers up the analog channel block
+of the controller to detect the touches.
+
+- vdd-supply: Digital power supply. It powers up the digital block
+of the controller to enable i2c communication.
+
 Example:
 
touch@4b {
@@ -38,4 +44,6 @@ Example:
reg = <0x4b>;
interrupt-parent = <&gpio>;
interrupts = ;
+   avdd-supply = <&atsp_reg>;
+   vdd-supply = <&tsp_reg>;
};
-- 
2.17.1



Re: [PATCH v2 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property

2019-01-07 Thread Paweł Chmiel
Dnia czwartek, 3 stycznia 2019 19:27:39 CET Rob Herring pisze:
> On Fri, Dec 28, 2018 at 4:52 PM Dmitry Torokhov
>  wrote:
> >
> > On Fri, Dec 28, 2018 at 2:47 PM Rob Herring  wrote:
> > >
> > > On Fri, 28 Dec 2018 16:46:07 +0100, =?UTF-8?q?Pawe=C5=82=20Chmiel?= wrote:
> > > > From: Jonathan Bakker 
> > > >
> > > > Document new optional property for setting custom keycodes.
> > > >
> > > > Signed-off-by: Jonathan Bakker 
> > > > Signed-off-by: Paweł Chmiel 
> > > > ---
> > > > Changes from v1:
> > > >   - Because key codes could be bigger than 255, use ints for keycodes
> > > > ---
> > > >  .../devicetree/bindings/input/cypress,tm2-touchkey.txt| 4 
> > > >  1 file changed, 4 insertions(+)
> > > >
> > >
> > > Reviewed-by: Rob Herring 
> >
> > Shouldn't this be "linux,keycodes" though?
> 
> Sigh, yes.
> 
> Rob
I'll send v3 version with this property name fixed (both in documentation and 
in driver).

Thanks





[PATCH v3 7/7] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey

2019-01-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Document compatible for aries touchkey.

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
Reviewed-by: Rob Herring 
---
Changes from v1:
  - Added Reviewed-by
---
 Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt 
b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index 8ef1517c0220..ef2ae729718f 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -4,6 +4,7 @@ Required properties:
 - compatible:
 * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
 * "cypress,midas-touchkey" - for the touchkey found on midas boards
+* "cypress,aries-touchkey" - for the touchkey found on aries boards
 - reg: I2C address of the chip.
 - interrupts: interrupt to which the chip is connected (see interrupt
binding[0]).
-- 
2.17.1



[PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property

2019-01-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Document new optional property for setting custom keycodes.

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
Changes from v2:
  - Change property name from keycodes to linux,keycodes

Changes from v1:
  - Because key codes could be bigger than 255, use ints for keycodes
---
 .../devicetree/bindings/input/cypress,tm2-touchkey.txt| 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt 
b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index dfb3b9f0ee40..8ef1517c0220 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -10,6 +10,9 @@ Required properties:
 - vcc-supply : internal regulator output. 1.8V
 - vdd-supply : power supply for IC 3.3V
 
+Optional properties:
+- linux,keycodes: array of keycodes (max 4), default KEY_PHONE and KEY_BACK
+
 [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
 
 Example:
@@ -23,5 +26,6 @@ Example:
interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
vcc-supply=<&ldo32_reg>;
vdd-supply=<&ldo33_reg>;
+   linux,keycodes = ;
};
};
-- 
2.17.1



[PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas

2019-01-07 Thread Paweł Chmiel
This patches adds support for Aries (Samsung i9000) and Midas (Samsung S3)
based devices to TM2 Touchkey driver.

Changes from v2:
  - Change property name from keycodes to linux,keycodes

Changes from v1:
  - Added Reviewed-by to some patches
  - Use ints for keycodes (they could be bigger than 255)
  - Droped separate name changes
  - Added missing const in few places
  - Removed redundant cast

Jonathan Bakker (5):
  Input: tm2-touchkey: Correct initial brightness
  Input: tm2-touchkey: Allow specifying custom keycodes
  Input: dt-bindings: tm2-touchkey: Document new keycodes property
  Input: tm2-touchkey: Add support for aries touchkey variant
  Input: dt-bindings: tm2-touchkey: Add support for aries touchkey

Simon Shields (2):
  Input: tm2-touchkey: Add support for midas touchkey
  Input: dt-bindings: tm2-touchkey: Add support for midas touchkey

 .../bindings/input/cypress,tm2-touchkey.txt   |   9 +-
 drivers/input/keyboard/tm2-touchkey.c | 132 +-
 2 files changed, 108 insertions(+), 33 deletions(-)

-- 
2.17.1



[PATCH v3 1/7] Input: tm2-touchkey: Add support for midas touchkey

2019-01-07 Thread Paweł Chmiel
From: Simon Shields 

The touchkey on midas boards is almost identical.
The only real difference is that it uses the same register for both
keycode and base.

Signed-off-by: Simon Shields 
Signed-off-by: Paweł Chmiel 
---
Changes from v1:
  - Droped separate name changes
  - Added missing const in few places
  - Removed redundant cast
---
 drivers/input/keyboard/tm2-touchkey.c | 34 +++
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index abc266e40e17..5a1fe08bdd76 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -22,12 +22,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #define TM2_TOUCHKEY_DEV_NAME  "tm2-touchkey"
-#define TM2_TOUCHKEY_KEYCODE_REG   0x03
-#define TM2_TOUCHKEY_BASE_REG  0x00
+
 #define TM2_TOUCHKEY_CMD_LED_ON0x10
 #define TM2_TOUCHKEY_CMD_LED_OFF   0x20
 #define TM2_TOUCHKEY_BIT_PRESS_EV  BIT(3)
@@ -40,12 +40,28 @@ enum {
TM2_TOUCHKEY_KEY_BACK,
 };
 
+struct touchkey_variant {
+   u8 keycode_reg;
+   u8 base_reg;
+};
+
 struct tm2_touchkey_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct led_classdev led_dev;
struct regulator *vdd;
struct regulator_bulk_data regulators[2];
+   const struct touchkey_variant *variant;
+};
+
+static const struct touchkey_variant tm2_touchkey_variant = {
+   .keycode_reg = 0x03,
+   .base_reg = 0x00,
+};
+
+static const struct touchkey_variant midas_touchkey_variant = {
+   .keycode_reg = 0x00,
+   .base_reg = 0x00,
 };
 
 static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
@@ -66,7 +82,7 @@ static void tm2_touchkey_led_brightness_set(struct 
led_classdev *led_dev,
 
regulator_set_voltage(touchkey->vdd, volt, volt);
i2c_smbus_write_byte_data(touchkey->client,
- TM2_TOUCHKEY_BASE_REG, data);
+ touchkey->variant->base_reg, data);
 }
 
 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
@@ -99,7 +115,7 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
int key;
 
data = i2c_smbus_read_byte_data(touchkey->client,
-   TM2_TOUCHKEY_KEYCODE_REG);
+   touchkey->variant->keycode_reg);
if (data < 0) {
dev_err(&touchkey->client->dev,
"failed to read i2c data: %d\n", data);
@@ -153,6 +169,8 @@ static int tm2_touchkey_probe(struct i2c_client *client,
touchkey->client = client;
i2c_set_clientdata(client, touchkey);
 
+   touchkey->variant = of_device_get_match_data(&client->dev);
+
touchkey->regulators[0].supply = "vcc";
touchkey->regulators[1].supply = "vdd";
error = devm_regulator_bulk_get(&client->dev,
@@ -262,7 +280,13 @@ static const struct i2c_device_id tm2_touchkey_id_table[] 
= {
 MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table);
 
 static const struct of_device_id tm2_touchkey_of_match[] = {
-   { .compatible = "cypress,tm2-touchkey", },
+   {
+   .compatible = "cypress,tm2-touchkey",
+   .data = &tm2_touchkey_variant,
+   }, {
+   .compatible = "cypress,midas-touchkey",
+   .data = &midas_touchkey_variant,
+   },
{ },
 };
 MODULE_DEVICE_TABLE(of, tm2_touchkey_of_match);
-- 
2.17.1



[PATCH v3 3/7] Input: tm2-touchkey: Correct initial brightness

2019-01-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Tm2-touchkey don't have brightness levels, but only on/off states,
so replace LED_FULL with LED_ON.

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
 drivers/input/keyboard/tm2-touchkey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index 5a1fe08bdd76..0336789ab1bb 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -230,7 +230,7 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 
/* led device */
touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
-   touchkey->led_dev.brightness = LED_FULL;
+   touchkey->led_dev.brightness = LED_ON;
touchkey->led_dev.max_brightness = LED_ON;
touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set;
 
-- 
2.17.1



[PATCH v3 4/7] Input: tm2-touchkey: Allow specifying custom keycodes

2019-01-07 Thread Paweł Chmiel
From: Jonathan Bakker 

Not all devices use the same keycodes in the same order,
so add possibility to define keycodes for buttons present
on actual hardware.

If keycodes property is not present, we assume that device has
at least MENU and BACK keys.

Signed-off-by: Jonathan Bakker 
Signed-off-by: Paweł Chmiel 
---
Changes from v2:
  - Change property name from keycodes to linux,keycodes

Changes from v1:
  - Because key codes could be bigger than 255, use ints for keycodes
---
 drivers/input/keyboard/tm2-touchkey.c | 49 +++
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index 0336789ab1bb..b55faf597d8a 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -35,11 +35,6 @@
 #define TM2_TOUCHKEY_LED_VOLTAGE_MIN   250
 #define TM2_TOUCHKEY_LED_VOLTAGE_MAX   330
 
-enum {
-   TM2_TOUCHKEY_KEY_MENU = 0x1,
-   TM2_TOUCHKEY_KEY_BACK,
-};
-
 struct touchkey_variant {
u8 keycode_reg;
u8 base_reg;
@@ -52,6 +47,8 @@ struct tm2_touchkey_data {
struct regulator *vdd;
struct regulator_bulk_data regulators[2];
const struct touchkey_variant *variant;
+   u32 keycodes[4];
+   int num_keycodes;
 };
 
 static const struct touchkey_variant tm2_touchkey_variant = {
@@ -112,7 +109,8 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
 {
struct tm2_touchkey_data *touchkey = devid;
int data;
-   int key;
+   int index;
+   int i;
 
data = i2c_smbus_read_byte_data(touchkey->client,
touchkey->variant->keycode_reg);
@@ -122,26 +120,20 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
goto out;
}
 
-   switch (data & TM2_TOUCHKEY_BIT_KEYCODE) {
-   case TM2_TOUCHKEY_KEY_MENU:
-   key = KEY_PHONE;
-   break;
-
-   case TM2_TOUCHKEY_KEY_BACK:
-   key = KEY_BACK;
-   break;
-
-   default:
+   index = (data & TM2_TOUCHKEY_BIT_KEYCODE) - 1;
+   if (index < 0 || index >= touchkey->num_keycodes) {
dev_warn(&touchkey->client->dev,
-"unhandled keycode, data %#02x\n", data);
+"invalid keycode index %d\n", index);
goto out;
}
 
if (data & TM2_TOUCHKEY_BIT_PRESS_EV) {
-   input_report_key(touchkey->input_dev, KEY_PHONE, 0);
-   input_report_key(touchkey->input_dev, KEY_BACK, 0);
+   for (i = 0; i < touchkey->num_keycodes; i++)
+   input_report_key(touchkey->input_dev,
+touchkey->keycodes[i], 0);
} else {
-   input_report_key(touchkey->input_dev, key, 1);
+   input_report_key(touchkey->input_dev,
+touchkey->keycodes[index], 1);
}
 
input_sync(touchkey->input_dev);
@@ -153,8 +145,10 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void 
*devid)
 static int tm2_touchkey_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
+   struct device_node *np = client->dev.of_node;
struct tm2_touchkey_data *touchkey;
int error;
+   int i;
 
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -184,6 +178,16 @@ static int tm2_touchkey_probe(struct i2c_client *client,
/* Save VDD for easy access */
touchkey->vdd = touchkey->regulators[1].consumer;
 
+   touchkey->num_keycodes = of_property_read_variable_u32_array(np,
+   "linux,keycodes", touchkey->keycodes, 0,
+   ARRAY_SIZE(touchkey->keycodes));
+   if (touchkey->num_keycodes <= 0) {
+   /* default keycodes */
+   touchkey->keycodes[0] = KEY_PHONE;
+   touchkey->keycodes[1] = KEY_BACK;
+   touchkey->num_keycodes = 2;
+   }
+
error = tm2_touchkey_power_enable(touchkey);
if (error) {
dev_err(&client->dev, "failed to power up device: %d\n", error);
@@ -208,8 +212,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
touchkey->input_dev->id.bustype = BUS_I2C;
 
-   input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE);
-   input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK);
+   for (i = 0; i < touchkey->num_keycodes; i++)
+   input_set_capability(touchkey->input_dev, EV_KEY,
+touchkey->keycodes[i]);
 
error = input_register_device(touchkey->input_dev);
if (error) {
-- 
2.17.1



[PATCH v3 2/7] Input: dt-bindings: tm2-touchkey: Add support for midas touchkey

2019-01-07 Thread Paweł Chmiel
From: Simon Shields 

Document compatible for midas touchkey.

Signed-off-by: Simon Shields 
Signed-off-by: Paweł Chmiel 
Reviewed-by: Rob Herring 
---
Changes from v1:
  - Added Reviewed-by
---
 .../devicetree/bindings/input/cypress,tm2-touchkey.txt| 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt 
b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index 0c252d9306da..dfb3b9f0ee40 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -1,7 +1,9 @@
 Samsung tm2-touchkey
 
 Required properties:
-- compatible: must be "cypress,tm2-touchkey"
+- compatible:
+* "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
+* "cypress,midas-touchkey" - for the touchkey found on midas boards
 - reg: I2C address of the chip.
 - interrupts: interrupt to which the chip is connected (see interrupt
binding[0]).
-- 
2.17.1



  1   2   3   >