diff mbox

[OpenWrt-Devel,2/3] brcm63xx: use bcm6345-gpio over legacy

Message ID 5488DCC9.6040205@gmail.com
State Changes Requested
Delegated to: Jonas Gorski
Headers show

Commit Message

Álvaro Fernández Rojas Dec. 10, 2014, 11:52 p.m. UTC
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---

Comments

Jonas Gorski Dec. 12, 2014, 2:17 p.m. UTC | #1
On Thu, Dec 11, 2014 at 12:52 AM, Álvaro Fernández Rojas
<noltari@gmail.com> wrote:
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
> diff --git a/target/linux/brcm63xx/patches-3.14/375-GPIO-DT-over-legacy.patch b/target/linux/brcm63xx/patches-3.14/375-GPIO-DT-over-legacy.patch
> new file mode 100644
> index 0000000..9c4f6ec
> --- /dev/null
> +++ b/target/linux/brcm63xx/patches-3.14/375-GPIO-DT-over-legacy.patch
> @@ -0,0 +1,93 @@
> +--- a/arch/mips/bcm63xx/boards/board_common.c
> ++++ b/arch/mips/bcm63xx/boards/board_common.c
> +@@ -191,8 +191,6 @@ static struct of_device_id of_ids[] = {
> +  */
> + int __init board_register_devices(void)
> + {
> +-      int button_count = 0;
> +-      int led_count = 0;
> +       int usbh_ports = 0;
> +
> + #if CONFIG_OF
> +@@ -204,6 +202,10 @@ int __init board_register_devices(void)
> +       }
> + #endif
> +
> ++      if (!board_of_device_present("gpio0")) {
> ++              bcm63xx_gpio_init();
> ++      }
> ++
> +       if (board.has_uart0)
> +               bcm63xx_uart_register(0);
> +
> +@@ -265,30 +267,35 @@ int __init board_register_devices(void)
> +
> +       bcm63xx_flash_register();
> +
> +-      /* count number of LEDs defined by this device */
> +-      while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
> +-              led_count++;
> +-
> +-      if (led_count) {
> +-              bcm63xx_led_data.num_leds = led_count;
> +-              bcm63xx_led_data.leds = board.leds;
> +-
> +-              platform_device_register(&bcm63xx_gpio_leds);
> +-      }
> +-
> +-      if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
> +-              gpio_request_one(board.ephy_reset_gpio,
> +-                              board.ephy_reset_gpio_flags, "ephy-reset");
> +-
> +-      /* count number of BUTTONs defined by this device */
> +-      while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
> +-              button_count++;
> +-
> +-      if (button_count) {
> +-              bcm63xx_gpio_keys_data.nbuttons = button_count;
> +-              bcm63xx_gpio_keys_data.buttons = board.buttons;

To keep the changes minimal, how about just

-      if (button_count) {
+      if (button_count && !board_of_device_present("gpio0")) {

Same for the leds.


Jonas
diff mbox

Patch

diff --git a/target/linux/brcm63xx/patches-3.14/375-GPIO-DT-over-legacy.patch b/target/linux/brcm63xx/patches-3.14/375-GPIO-DT-over-legacy.patch
new file mode 100644
index 0000000..9c4f6ec
--- /dev/null
+++ b/target/linux/brcm63xx/patches-3.14/375-GPIO-DT-over-legacy.patch
@@ -0,0 +1,93 @@ 
+--- a/arch/mips/bcm63xx/boards/board_common.c
++++ b/arch/mips/bcm63xx/boards/board_common.c
+@@ -191,8 +191,6 @@ static struct of_device_id of_ids[] = {
+  */
+ int __init board_register_devices(void)
+ {
+-	int button_count = 0;
+-	int led_count = 0;
+ 	int usbh_ports = 0;
+ 
+ #if CONFIG_OF
+@@ -204,6 +202,10 @@ int __init board_register_devices(void)
+ 	}
+ #endif
+ 
++	if (!board_of_device_present("gpio0")) {
++		bcm63xx_gpio_init();
++	}
++
+ 	if (board.has_uart0)
+ 		bcm63xx_uart_register(0);
+ 
+@@ -265,30 +267,35 @@ int __init board_register_devices(void)
+ 
+ 	bcm63xx_flash_register();
+ 
+-	/* count number of LEDs defined by this device */
+-	while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
+-		led_count++;
+-
+-	if (led_count) {
+-		bcm63xx_led_data.num_leds = led_count;
+-		bcm63xx_led_data.leds = board.leds;
+-
+-		platform_device_register(&bcm63xx_gpio_leds);
+-	}
+-
+-	if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
+-		gpio_request_one(board.ephy_reset_gpio,
+-				board.ephy_reset_gpio_flags, "ephy-reset");
+-
+-	/* count number of BUTTONs defined by this device */
+-	while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
+-		button_count++;
+-
+-	if (button_count) {
+-		bcm63xx_gpio_keys_data.nbuttons = button_count;
+-		bcm63xx_gpio_keys_data.buttons = board.buttons;
++	if (!board_of_device_present("gpio0")) {
++		int led_count = 0;
++		int button_count = 0;
++
++		/* count number of LEDs defined by this device */
++		while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
++			led_count++;
++
++		if (led_count) {
++			bcm63xx_led_data.num_leds = led_count;
++			bcm63xx_led_data.leds = board.leds;
++
++			platform_device_register(&bcm63xx_gpio_leds);
++		}
++
++		if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
++			gpio_request_one(board.ephy_reset_gpio,
++					board.ephy_reset_gpio_flags, "ephy-reset");
++
++		/* count number of BUTTONs defined by this device */
++		while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
++			button_count++;
++
++		if (button_count) {
++			bcm63xx_gpio_keys_data.nbuttons = button_count;
++			bcm63xx_gpio_keys_data.buttons = board.buttons;
+ 
+-		platform_device_register(&bcm63xx_gpio_keys_device);
++			platform_device_register(&bcm63xx_gpio_keys_device);
++		}
+ 	}
+ 
+ 	return 0;
+--- a/arch/mips/bcm63xx/prom.c
++++ b/arch/mips/bcm63xx/prom.c
+@@ -54,9 +54,6 @@ void __init prom_init(void)
+ 	reg &= ~mask;
+ 	bcm_perf_writel(reg, PERF_CKCTL_REG);
+ 
+-	/* register gpiochip */
+-	bcm63xx_gpio_init();
+-
+ 	/* detect and setup flash access */
+ 	bcm63xx_flash_detect();
+ 
diff --git a/target/linux/brcm63xx/patches-3.18/375-GPIO-DT-over-legacy.patch b/target/linux/brcm63xx/patches-3.18/375-GPIO-DT-over-legacy.patch
new file mode 100755
index 0000000..9c4f6ec
--- /dev/null
+++ b/target/linux/brcm63xx/patches-3.18/375-GPIO-DT-over-legacy.patch
@@ -0,0 +1,93 @@ 
+--- a/arch/mips/bcm63xx/boards/board_common.c
++++ b/arch/mips/bcm63xx/boards/board_common.c
+@@ -191,8 +191,6 @@ static struct of_device_id of_ids[] = {
+  */
+ int __init board_register_devices(void)
+ {
+-	int button_count = 0;
+-	int led_count = 0;
+ 	int usbh_ports = 0;
+ 
+ #if CONFIG_OF
+@@ -204,6 +202,10 @@ int __init board_register_devices(void)
+ 	}
+ #endif
+ 
++	if (!board_of_device_present("gpio0")) {
++		bcm63xx_gpio_init();
++	}
++
+ 	if (board.has_uart0)
+ 		bcm63xx_uart_register(0);
+ 
+@@ -265,30 +267,35 @@ int __init board_register_devices(void)
+ 
+ 	bcm63xx_flash_register();
+ 
+-	/* count number of LEDs defined by this device */
+-	while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
+-		led_count++;
+-
+-	if (led_count) {
+-		bcm63xx_led_data.num_leds = led_count;
+-		bcm63xx_led_data.leds = board.leds;
+-
+-		platform_device_register(&bcm63xx_gpio_leds);
+-	}
+-
+-	if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
+-		gpio_request_one(board.ephy_reset_gpio,
+-				board.ephy_reset_gpio_flags, "ephy-reset");
+-
+-	/* count number of BUTTONs defined by this device */
+-	while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
+-		button_count++;
+-
+-	if (button_count) {
+-		bcm63xx_gpio_keys_data.nbuttons = button_count;
+-		bcm63xx_gpio_keys_data.buttons = board.buttons;
++	if (!board_of_device_present("gpio0")) {
++		int led_count = 0;
++		int button_count = 0;
++
++		/* count number of LEDs defined by this device */
++		while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
++			led_count++;
++
++		if (led_count) {
++			bcm63xx_led_data.num_leds = led_count;
++			bcm63xx_led_data.leds = board.leds;
++
++			platform_device_register(&bcm63xx_gpio_leds);
++		}
++
++		if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
++			gpio_request_one(board.ephy_reset_gpio,
++					board.ephy_reset_gpio_flags, "ephy-reset");
++
++		/* count number of BUTTONs defined by this device */
++		while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
++			button_count++;
++
++		if (button_count) {
++			bcm63xx_gpio_keys_data.nbuttons = button_count;
++			bcm63xx_gpio_keys_data.buttons = board.buttons;
+ 
+-		platform_device_register(&bcm63xx_gpio_keys_device);
++			platform_device_register(&bcm63xx_gpio_keys_device);
++		}
+ 	}
+ 
+ 	return 0;
+--- a/arch/mips/bcm63xx/prom.c
++++ b/arch/mips/bcm63xx/prom.c
+@@ -54,9 +54,6 @@ void __init prom_init(void)
+ 	reg &= ~mask;
+ 	bcm_perf_writel(reg, PERF_CKCTL_REG);
+ 
+-	/* register gpiochip */
+-	bcm63xx_gpio_init();
+-
+ 	/* detect and setup flash access */
+ 	bcm63xx_flash_detect();
+