Skip to contentSkip to conversation

sunxi: Fix gmac not working on the Colombus board

PATCH New Hans de Goede 3 participants 7 messages Aug 6, 2015 – Aug 18, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sunxi: Fix gmac not working on the Colombus board

The phy is using a RGMII interface, which we need to specify in our board-config, and the dts needs a gmac section (the dts changes have also been submitted to the kernel).

---
 arch/arm/dts/sun6i-a31-colombus.dts | 12 ++++++++++++
 configs/Colombus_defconfig          |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
arch/arm/dts/sun6i-a31-colombus.dts +12 -0
index 0cf9926..0d0b6f2 100644
@@ -66,6 +66,18 @@
 	status = "okay";
 };
 
+&gmac {
+	pinctrl-names = "default";
+	pinctrl-0 = <&gmac_pins_rgmii_a>;
+	phy = <&phy1>;
+	phy-mode = "rgmii";
+	status = "okay";
+
+	phy1: ethernet-phy at 1 {
+		reg = <1>;
+	};
+};
+
 &i2c0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&i2c0_pins_a>;
configs/Colombus_defconfig +1 -1
index 1ae8c16..7fa9ef1 100644
@@ -7,7 +7,7 @@ CONFIG_USB1_VBUS_PIN=""
 CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-colombus"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC"
+CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
Signature · 1 line
2.4.3
#1 lore raw

PATCH 2/2 sunxi: gpio: Add support for the gpio banks which are part of the R-io cluster

sun6i and later have a couple of io-blocks which are shared between the main CPU core and the "R" cpu which is small embedded cpu which can be active while the main system is suspended.

These gpio banks sit at a different mmio address then the normal banks, and have a separate devicetree node and compatible, this adds support for these banks to the sunxi-gpio code when built with device-model support.

---
 drivers/gpio/sunxi_gpio.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/gpio/sunxi_gpio.c +18 -4
index afa165a..57b78e5 100644
@@ -266,16 +266,28 @@ static int gpio_sunxi_bind(struct udevice *parent)
 {
 	struct sunxi_gpio_platdata *plat = parent->platdata;
 	struct sunxi_gpio_reg *ctlr;
-	int bank;
-	int ret;
+	int bank, no_banks, ret, start;
 
 	/* If this is a child device, there is nothing to do here */
 	if (plat)
 		return 0;
 
+	if (fdt_node_check_compatible(gd->fdt_blob, parent->of_offset,
+				"allwinner,sun6i-a31-r-pinctrl") == 0) {
+		start = 'L' - 'A';
+		no_banks = 2; /* L & M */
+	} else if (fdt_node_check_compatible(gd->fdt_blob, parent->of_offset,
+				"allwinner,sun8i-a23-r-pinctrl") == 0) {
+		start = 'L' - 'A';
+		no_banks = 1; /* L only */
+	} else {
+		start = 0;
+		no_banks = SUNXI_GPIO_BANKS;
+	}
+
 	ctlr = (struct sunxi_gpio_reg *)fdtdec_get_addr(gd->fdt_blob,
 						   parent->of_offset, "reg");
-	for (bank = 0; bank < SUNXI_GPIO_BANKS; bank++) {
+	for (bank = 0; bank < no_banks; bank++) {
 		struct sunxi_gpio_platdata *plat;
 		struct udevice *dev;
 
@@ -283,7 +295,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
 		if (!plat)
 			return -ENOMEM;
 		plat->regs = &ctlr->gpio_bank[bank];
-		plat->bank_name = gpio_bank_name(bank);
+		plat->bank_name = gpio_bank_name(start + bank);
 		plat->gpio_count = SUNXI_GPIOS_PER_BANK;
 
 		ret = device_bind(parent, parent->driver,
@@ -306,6 +318,8 @@ static const struct udevice_id sunxi_gpio_ids[] = {
 	{ .compatible = "allwinner,sun8i-a23-pinctrl" },
 	{ .compatible = "allwinner,sun8i-a33-pinctrl" },
 	{ .compatible = "allwinner,sun9i-a80-pinctrl" },
+	{ .compatible = "allwinner,sun6i-a31-r-pinctrl" },
+	{ .compatible = "allwinner,sun8i-a23-r-pinctrl" },
 	{ }
 };
 
Signature · 1 line
2.4.3
#2 lore raw

PATCH 2/2 sunxi: gpio: Add support for the gpio banks which are part of the R-io cluster

Quoted 6 lines · Hans de Goede

sun6i and later have a couple of io-blocks which are shared between the
main CPU core and the "R" cpu which is small embedded cpu which can be
active while the main system is suspended.

Quoted 8 lines

These gpio banks sit at a different mmio address then the normal banks,
and have a separate devicetree node and compatible, this adds support for
these banks to the sunxi-gpio code when built with device-model support.

#3 lore raw

PATCH 2/2 sunxi: gpio: Add support for the gpio banks which are part of the R-io cluster

In reply to Hans de Goede

Hi Hans,

Quoted 21 lines · Hans de Goede

sun6i and later have a couple of io-blocks which are shared between the main CPU core and the "R" cpu which is small embedded cpu which can be active while the main system is suspended.

These gpio banks sit at a different mmio address then the normal banks, and have a separate devicetree node and compatible, this adds support for these banks to the sunxi-gpio code when built with device-model support.

---
 drivers/gpio/sunxi_gpio.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/gpio/sunxi_gpio.c +0 -0
index afa165a..57b78e5 100644
@@ -266,16 +266,28 @@ static int gpio_sunxi_bind(struct udevice *parent)
 {
        struct sunxi_gpio_platdata *plat = parent->platdata;
        struct sunxi_gpio_reg *ctlr;

drivers/gpio/sunxi_gpio.c static int gpio_sunxi_bind(struct udevice *parent) · line 276

Quoted 10 lines
drivers/gpio/sunxi_gpio.c +3 -2
-       int bank;
-       int ret;
+       int bank, no_banks, ret, start;
 
        /* If this is a child device, there is nothing to do here */
        if (plat)
                return 0;
 
+       if (fdt_node_check_compatible(gd->fdt_blob, parent->of_offset,
+                               "allwinner,sun6i-a31-r-pinctrl") == 0) {

If I understand what you are doing here, the correct way is to use a .data field in sunxi_gpio_ids[] below. In any case you should not be checking the compatible string of a parent.

Quoted 39 lines
drivers/gpio/sunxi_gpio.c +15 -3
+               start = 'L' - 'A';
+               no_banks = 2; /* L & M */
+       } else if (fdt_node_check_compatible(gd->fdt_blob, parent->of_offset,
+                               "allwinner,sun8i-a23-r-pinctrl") == 0) {
+               start = 'L' - 'A';
+               no_banks = 1; /* L only */
+       } else {
+               start = 0;
+               no_banks = SUNXI_GPIO_BANKS;
+       }
+
        ctlr = (struct sunxi_gpio_reg *)fdtdec_get_addr(gd->fdt_blob,
                                                   parent->of_offset, "reg");
-       for (bank = 0; bank < SUNXI_GPIO_BANKS; bank++) {
+       for (bank = 0; bank < no_banks; bank++) {
                struct sunxi_gpio_platdata *plat;
                struct udevice *dev;
 
@@ -283,7 +295,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
                if (!plat)
                        return -ENOMEM;
                plat->regs = &ctlr->gpio_bank[bank];
-               plat->bank_name = gpio_bank_name(bank);
+               plat->bank_name = gpio_bank_name(start + bank);
                plat->gpio_count = SUNXI_GPIOS_PER_BANK;
 
                ret = device_bind(parent, parent->driver,
@@ -306,6 +318,8 @@ static const struct udevice_id sunxi_gpio_ids[] = {
        { .compatible = "allwinner,sun8i-a23-pinctrl" },
        { .compatible = "allwinner,sun8i-a33-pinctrl" },
        { .compatible = "allwinner,sun9i-a80-pinctrl" },
+       { .compatible = "allwinner,sun6i-a31-r-pinctrl" },
+       { .compatible = "allwinner,sun8i-a23-r-pinctrl" },
        { }
 };
 
--

2.4.3

Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Simon

#4 lore raw

PATCH 2/2 sunxi: gpio: Add support for the gpio banks which are part of the R-io cluster

Hi,

Quoted 32 lines · Simon Glass

Hi Hans,

Quoted 29 lines · Hans de Goede

sun6i and later have a couple of io-blocks which are shared between the main CPU core and the "R" cpu which is small embedded cpu which can be active while the main system is suspended.

These gpio banks sit at a different mmio address then the normal banks, and have a separate devicetree node and compatible, this adds support for these banks to the sunxi-gpio code when built with device-model support.

---
  drivers/gpio/sunxi_gpio.c | 22 ++++++++++++++++++----
  1 file changed, 18 insertions(+), 4 deletions(-)
drivers/gpio/sunxi_gpio.c +1 -2
index afa165a..57b78e5 100644
@@ -266,16 +266,28 @@ static int gpio_sunxi_bind(struct udevice *parent)
  {
         struct sunxi_gpio_platdata *plat = parent->platdata;
         struct sunxi_gpio_reg *ctlr;
-       int bank;
-       int ret;
+       int bank, no_banks, ret, start;
 
         /* If this is a child device, there is nothing to do here */
         if (plat)
                 return 0;
 
Quoted 5 lines

drivers/gpio/sunxi_gpio.c static int gpio_sunxi_bind(struct udevice *parent) · line 276

Quoted 2 lines
drivers/gpio/sunxi_gpio.c +2 -0
+       if (fdt_node_check_compatible(gd->fdt_blob, parent->of_offset,
+                               "allwinner,sun6i-a31-r-pinctrl") == 0) {

If I understand what you are doing here, the correct way is to use a .data field in sunxi_gpio_ids[] below.

Yes that would work too, but that indirection makes it harder to follow what the code is doing without giving us much benefit IMHO.

Quoted 2 lines

In any case you should not be
checking the compatible string of a parent.

AFAICT this is the right way to check a compatible string in a bind function, the parent variable name here is confusing as this actually points to the udevice passed into the bind function, not its parent. I guess it is named parent rather then device to distinguish it from the per bank gpio udevices the bind function is instantiating.

So I'm not really checking the parents compatible but its own, it just looks that way because of the bind function parameter name being parent.

Regards,

Hans

Quoted 48 lines
Quoted 40 lines
drivers/gpio/sunxi_gpio.c +15 -3
+               start = 'L' - 'A';
+               no_banks = 2; /* L & M */
+       } else if (fdt_node_check_compatible(gd->fdt_blob, parent->of_offset,
+                               "allwinner,sun8i-a23-r-pinctrl") == 0) {
+               start = 'L' - 'A';
+               no_banks = 1; /* L only */
+       } else {
+               start = 0;
+               no_banks = SUNXI_GPIO_BANKS;
+       }
+
         ctlr = (struct sunxi_gpio_reg *)fdtdec_get_addr(gd->fdt_blob,
                                                    parent->of_offset, "reg");
-       for (bank = 0; bank < SUNXI_GPIO_BANKS; bank++) {
+       for (bank = 0; bank < no_banks; bank++) {
                 struct sunxi_gpio_platdata *plat;
                 struct udevice *dev;
 
@@ -283,7 +295,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
                 if (!plat)
                         return -ENOMEM;
                 plat->regs = &ctlr->gpio_bank[bank];
-               plat->bank_name = gpio_bank_name(bank);
+               plat->bank_name = gpio_bank_name(start + bank);
                 plat->gpio_count = SUNXI_GPIOS_PER_BANK;
 
                 ret = device_bind(parent, parent->driver,
@@ -306,6 +318,8 @@ static const struct udevice_id sunxi_gpio_ids[] = {
         { .compatible = "allwinner,sun8i-a23-pinctrl" },
         { .compatible = "allwinner,sun8i-a33-pinctrl" },
         { .compatible = "allwinner,sun9i-a80-pinctrl" },
+       { .compatible = "allwinner,sun6i-a31-r-pinctrl" },
+       { .compatible = "allwinner,sun8i-a23-r-pinctrl" },
         { }
  };
 
--

2.4.3

Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Simon

#5 lore raw

PATCH 2/2 sunxi: gpio: Add support for the gpio banks which are part of the R-io cluster

Hi Hans,

Quoted 53 lines · Hans de Goede

Hi,

Quoted 34 lines · Simon Glass

Hi Hans,

Quoted 30 lines · Hans de Goede

sun6i and later have a couple of io-blocks which are shared between the main CPU core and the "R" cpu which is small embedded cpu which can be active while the main system is suspended.

These gpio banks sit at a different mmio address then the normal banks, and have a separate devicetree node and compatible, this adds support for these banks to the sunxi-gpio code when built with device-model support.

---
  drivers/gpio/sunxi_gpio.c | 22 ++++++++++++++++++----
  1 file changed, 18 insertions(+), 4 deletions(-)
drivers/gpio/sunxi_gpio.c +1 -2
index afa165a..57b78e5 100644
@@ -266,16 +266,28 @@ static int gpio_sunxi_bind(struct udevice *parent)
  {
         struct sunxi_gpio_platdata *plat = parent->platdata;
         struct sunxi_gpio_reg *ctlr;
-       int bank;
-       int ret;
+       int bank, no_banks, ret, start;
 
         /* If this is a child device, there is nothing to do here */
         if (plat)
                 return 0;
 
Quoted 6 lines

drivers/gpio/sunxi_gpio.c static int gpio_sunxi_bind(struct udevice *parent) · line 276

Quoted 2 lines
drivers/gpio/sunxi_gpio.c +2 -0
+       if (fdt_node_check_compatible(gd->fdt_blob, parent->of_offset,
+                               "allwinner,sun6i-a31-r-pinctrl") == 0) {

If I understand what you are doing here, the correct way is to use a .data field in sunxi_gpio_ids[] below.

Yes that would work too, but that indirection makes it harder to follow what the code is doing without giving us much benefit IMHO.

Quoted 2 lines

In any case you should not be
checking the compatible string of a parent.

Quoted 6 lines

AFAICT this is the right way to check a compatible string in a bind function,
the parent variable name here is confusing as this actually points to the udevice passed into the bind function, not its parent. I guess it is named parent rather then device to distinguish it from the per bank gpio udevices the bind function is instantiating.

Sounds fine.

Quoted 3 lines

So I'm not really checking the parents compatible but its own, it just looks that way because of the bind function parameter name being parent.

See for example, drivers/i2c/tegra_i2c.c:

static const struct udevice_id tegra_i2c_ids[] = { { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 }, { .compatible = "nvidia,tegra20-i2c", .data = TYPE_STD }, { .compatible = "nvidia,tegra20-i2c-dvc", .data = TYPE_DVC }, { }
};

...

i2c_bus->type = dev_get_driver_data(dev);

which gets the 'data' value. So it's pretty easy to use and is the standard way to make a driver support multiple hardware types.

Quoted 46 lines

Regards,

Hans

Quoted 39 lines
Quoted 39 lines
drivers/gpio/sunxi_gpio.c +12 -1
+               start = 'L' - 'A';
+               no_banks = 2; /* L & M */
+       } else if (fdt_node_check_compatible(gd->fdt_blob,
 parent->of_offset,
+                               "allwinner,sun8i-a23-r-pinctrl") == 0) {
+               start = 'L' - 'A';
+               no_banks = 1; /* L only */
+       } else {
+               start = 0;
+               no_banks = SUNXI_GPIO_BANKS;
+       }
+
         ctlr = (struct sunxi_gpio_reg *)fdtdec_get_addr(gd->fdt_blob,
                                                    parent->of_offset,
 "reg");
-       for (bank = 0; bank < SUNXI_GPIO_BANKS; bank++) {
+       for (bank = 0; bank < no_banks; bank++) {
                 struct sunxi_gpio_platdata *plat;
                 struct udevice *dev;
drivers/gpio/sunxi_gpio.c +3 -1
@@ -283,7 +295,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
                 if (!plat)
                         return -ENOMEM;
                 plat->regs = &ctlr->gpio_bank[bank];
-               plat->bank_name = gpio_bank_name(bank);
+               plat->bank_name = gpio_bank_name(start + bank);
                 plat->gpio_count = SUNXI_GPIOS_PER_BANK;
 
                 ret = device_bind(parent, parent->driver,
@@ -306,6 +318,8 @@ static const struct udevice_id sunxi_gpio_ids[] = {
         { .compatible = "allwinner,sun8i-a23-pinctrl" },
         { .compatible = "allwinner,sun8i-a33-pinctrl" },
         { .compatible = "allwinner,sun9i-a80-pinctrl" },
+       { .compatible = "allwinner,sun6i-a31-r-pinctrl" },
+       { .compatible = "allwinner,sun8i-a23-r-pinctrl" },
         { }
  };
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

--
2.4.3

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Simon