Re: [U-Boot] [PATCH v2 11/18] pinctrl: MediaTek: add pinctrl driver for MT7623 SoC

2018-11-03 Thread Simon Glass
Hi Ryder,

On 25 October 2018 at 00:13, Ryder Lee  wrote:
> On Wed, 2018-10-24 at 21:29 -0600, Simon Glass wrote:
>> Hi Ryder,
>>
>> On 12 October 2018 at 01:01, Ryder Lee  wrote:
>> > This patch adds pinctrl support for MT7623 SoC. And most of the
>> > structures are used to hold the hardware configuration for each
>> > pin.
>> >
>> > Signed-off-by: Ryder Lee 
>> > Tested-by: Matthias Brugger 
>> > ---
>> >  drivers/pinctrl/mediatek/Kconfig  |4 +
>> >  drivers/pinctrl/mediatek/Makefile |1 +
>> >  drivers/pinctrl/mediatek/pinctrl-mt7623.c | 1284 
>> > +
>> >  drivers/pinctrl/mediatek/pinctrl-mtk-common.h |1 +
>> >  4 files changed, 1290 insertions(+)
>> >  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7623.c
>>
>> [..]
>>
>> > +void mtk_rmw(struct udevice *dev, u32 reg, u32 mask, u32 set);
>>
>> What is this for? It has no comment and is an exported function. We
>> should not export things from drivers unless there is a good reason.
>
> This is a common 'read-modify-write' helper. I think we could export it
> in this shared header?

OK I see, fair enough. Please add a comment to the function.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 11/18] pinctrl: MediaTek: add pinctrl driver for MT7623 SoC

2018-10-25 Thread Ryder Lee
On Wed, 2018-10-24 at 21:29 -0600, Simon Glass wrote:
> Hi Ryder,
> 
> On 12 October 2018 at 01:01, Ryder Lee  wrote:
> > This patch adds pinctrl support for MT7623 SoC. And most of the
> > structures are used to hold the hardware configuration for each
> > pin.
> >
> > Signed-off-by: Ryder Lee 
> > Tested-by: Matthias Brugger 
> > ---
> >  drivers/pinctrl/mediatek/Kconfig  |4 +
> >  drivers/pinctrl/mediatek/Makefile |1 +
> >  drivers/pinctrl/mediatek/pinctrl-mt7623.c | 1284 
> > +
> >  drivers/pinctrl/mediatek/pinctrl-mtk-common.h |1 +
> >  4 files changed, 1290 insertions(+)
> >  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7623.c
> 
> [..]
> 
> > +void mtk_rmw(struct udevice *dev, u32 reg, u32 mask, u32 set);
> 
> What is this for? It has no comment and is an exported function. We
> should not export things from drivers unless there is a good reason.

This is a common 'read-modify-write' helper. I think we could export it
in this shared header?

> Regards,
> Simon


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 11/18] pinctrl: MediaTek: add pinctrl driver for MT7623 SoC

2018-10-24 Thread Simon Glass
Hi Ryder,

On 12 October 2018 at 01:01, Ryder Lee  wrote:
> This patch adds pinctrl support for MT7623 SoC. And most of the
> structures are used to hold the hardware configuration for each
> pin.
>
> Signed-off-by: Ryder Lee 
> Tested-by: Matthias Brugger 
> ---
>  drivers/pinctrl/mediatek/Kconfig  |4 +
>  drivers/pinctrl/mediatek/Makefile |1 +
>  drivers/pinctrl/mediatek/pinctrl-mt7623.c | 1284 
> +
>  drivers/pinctrl/mediatek/pinctrl-mtk-common.h |1 +
>  4 files changed, 1290 insertions(+)
>  create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7623.c

[..]

> +void mtk_rmw(struct udevice *dev, u32 reg, u32 mask, u32 set);

What is this for? It has no comment and is an exported function. We
should not export things from drivers unless there is a good reason.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 11/18] pinctrl: MediaTek: add pinctrl driver for MT7623 SoC

2018-10-12 Thread Ryder Lee
This patch adds pinctrl support for MT7623 SoC. And most of the
structures are used to hold the hardware configuration for each
pin.

Signed-off-by: Ryder Lee 
Tested-by: Matthias Brugger 
---
 drivers/pinctrl/mediatek/Kconfig  |4 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt7623.c | 1284 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common.h |1 +
 4 files changed, 1290 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7623.c

diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
index e0145b1..1bd9a92 100644
--- a/drivers/pinctrl/mediatek/Kconfig
+++ b/drivers/pinctrl/mediatek/Kconfig
@@ -4,6 +4,10 @@ config PINCTRL_MTK
depends on PINCTRL_GENERIC
bool
 
+config PINCTRL_MT7623
+   bool "MT7623 SoC pinctrl driver"
+   select PINCTRL_MTK
+
 config PINCTRL_MT7629
bool "MT7629 SoC pinctrl driver"
select PINCTRL_MTK
diff --git a/drivers/pinctrl/mediatek/Makefile 
b/drivers/pinctrl/mediatek/Makefile
index cbf0765..f6ef362 100644
--- a/drivers/pinctrl/mediatek/Makefile
+++ b/drivers/pinctrl/mediatek/Makefile
@@ -3,4 +3,5 @@
 obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o
 
 # SoC Drivers
+obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o
 obj-$(CONFIG_PINCTRL_MT7629) += pinctrl-mt7629.o
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7623.c 
b/drivers/pinctrl/mediatek/pinctrl-mt7623.c
new file mode 100644
index 000..6fa3e2b
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7623.c
@@ -0,0 +1,1284 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 MediaTek Inc.
+ * Author: Ryder Lee 
+ */
+
+#include 
+
+#include "pinctrl-mtk-common.h"
+
+#define PIN_BOND_REG0  0xb10
+#define PIN_BOND_REG1  0xf20
+#define PIN_BOND_REG2  0xef0
+#define BOND_PCIE_CLR  (0x77 << 3)
+#define BOND_I2S_CLR   0x3
+#define BOND_MSDC0E_CLR0x1
+
+#define PIN_FIELD15(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits)
\
+   PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit,   \
+  _x_bits, 15, false)
+
+#define PIN_FIELD16(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits)
\
+   PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit,   \
+  _x_bits, 16, false)
+
+#define PINS_FIELD16(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits)\
+   PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit,   \
+  _x_bits, 16, true)
+
+static const struct mtk_pin_field_calc mt7623_pin_mode_range[] = {
+   PIN_FIELD15(0, 278, 0x760, 0x10, 0, 3),
+};
+
+static const struct mtk_pin_field_calc mt7623_pin_dir_range[] = {
+   PIN_FIELD16(0, 175, 0x0, 0x10, 0, 1),
+   PIN_FIELD16(176, 278, 0xc0, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt7623_pin_di_range[] = {
+   PIN_FIELD16(0, 278, 0x630, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt7623_pin_do_range[] = {
+   PIN_FIELD16(0, 278, 0x500, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt7623_pin_ies_range[] = {
+   PINS_FIELD16(0, 6, 0xb20, 0x10, 0, 1),
+   PINS_FIELD16(7, 9, 0xb20, 0x10, 1, 1),
+   PINS_FIELD16(10, 13, 0xb30, 0x10, 3, 1),
+   PINS_FIELD16(14, 15, 0xb30, 0x10, 13, 1),
+   PINS_FIELD16(16, 17, 0xb40, 0x10, 7, 1),
+   PINS_FIELD16(18, 29, 0xb40, 0x10, 13, 1),
+   PINS_FIELD16(30, 32, 0xb40, 0x10, 7, 1),
+   PINS_FIELD16(33, 37, 0xb40, 0x10, 13, 1),
+   PIN_FIELD16(38, 38, 0xb20, 0x10, 13, 1),
+   PINS_FIELD16(39, 42, 0xb40, 0x10, 13, 1),
+   PINS_FIELD16(43, 45, 0xb20, 0x10, 10, 1),
+   PINS_FIELD16(47, 48, 0xb20, 0x10, 11, 1),
+   PIN_FIELD16(49, 49, 0xb20, 0x10, 12, 1),
+   PINS_FIELD16(50, 52, 0xb20, 0x10, 13, 1),
+   PINS_FIELD16(53, 56, 0xb20, 0x10, 14, 1),
+   PINS_FIELD16(57, 58, 0xb20, 0x10, 15, 1),
+   PIN_FIELD16(59, 59, 0xb30, 0x10, 10, 1),
+   PINS_FIELD16(60, 62, 0xb30, 0x10, 0, 1),
+   PINS_FIELD16(63, 65, 0xb30, 0x10, 1, 1),
+   PINS_FIELD16(66, 71, 0xb30, 0x10, 2, 1),
+   PINS_FIELD16(72, 74, 0xb20, 0x10, 12, 1),
+   PINS_FIELD16(75, 76, 0xb30, 0x10, 3, 1),
+   PINS_FIELD16(77, 78, 0xb30, 0x10, 4, 1),
+   PINS_FIELD16(79, 82, 0xb30, 0x10, 5, 1),
+   PINS_FIELD16(83, 84, 0xb30, 0x10, 2, 1),
+   PIN_FIELD16(85, 85, 0xda0, 0x10, 4, 1),
+   PIN_FIELD16(86, 86, 0xd90, 0x10, 4, 1),
+   PINS_FIELD16(87, 90, 0xdb0, 0x10, 4, 1),
+   PINS_FIELD16(101, 104, 0xb30, 0x10, 6, 1),
+   PIN_FIELD16(105, 105, 0xd40, 0x10, 4, 1),
+   PIN_FIELD16(106, 106, 0xd30, 0x10, 4, 1),
+   PINS_FIELD16(107, 110, 0xd50, 0x10, 4, 1),
+   PINS_FIELD16(111, 115, 0xce0, 0x10, 4, 1),
+   PIN_FIELD16(116, 116, 0xcd0, 0x10, 4, 1),
+   PIN_FIELD16(117, 117, 0xcc0, 0x10, 4, 1),
+   PINS_FIELD16(118, 121, 0xce0, 0x10, 4, 1),
+   PINS_FIELD16(122,