* [PATCH 0/6 v2] raspberry-pi: updates @ 2015-01-13 6:31 Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD ` (2 more replies) 0 siblings, 3 replies; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:31 UTC (permalink / raw) To: barebox Hi, v2: send correct leds patch The following patch serie prepare the raspberry for USB support The following changes since commit 9cd14d260aa22ae089f81a07be2c0e5dea2ffc94: Merge branch 'for-next/pbl-console' (2015-01-09 17:38:27 +0100) are available in the git repository at: git://git.jcrosoft.org/barebox.git delivery/rpi for you to fetch changes up to 70d2d564af770d99c0e8a4fbfa314e6d55d58629: regulator: add bcm2835 driver (2015-01-11 19:04:06 +0800) ---------------------------------------------------------------- Jean-Christophe PLAGNIOL-VILLARD (6): raspberry-pi: add board model detection raspberry-pi: add leds support amba: pl011: add support for regulator driver: add postcore_platform_driver regulator: allow to use it with non DT device regulator: add bcm2835 driver arch/arm/boards/raspberry-pi/env/init/ps1 | 7 +++++++ arch/arm/boards/raspberry-pi/rpi.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- arch/arm/mach-bcm2835/include/mach/mbox.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/regulator/Kconfig | 7 ++++++- drivers/regulator/Makefile | 1 + drivers/regulator/bcm2835.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/regulator/core.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------- drivers/serial/amba-pl011.c | 11 +++++++++++ include/driver.h | 2 ++ include/regulator.h | 10 ++++++++++ 10 files changed, 488 insertions(+), 18 deletions(-) create mode 100644 arch/arm/boards/raspberry-pi/env/init/ps1 create mode 100644 drivers/regulator/bcm2835.c Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/6] raspberry-pi: add board model detection 2015-01-13 6:31 [PATCH 0/6 v2] raspberry-pi: updates Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 2/6] raspberry-pi: add leds support Jean-Christophe PLAGNIOL-VILLARD ` (4 more replies) 2015-01-14 6:24 ` [PATCH 0/6 v2] raspberry-pi: updates Sascha Hauer 2015-01-18 22:20 ` Antony Pavlov 2 siblings, 5 replies; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 UTC (permalink / raw) To: barebox as the name is very long, return ps1 to the next line Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/boards/raspberry-pi/env/init/ps1 | 7 +++ arch/arm/boards/raspberry-pi/rpi.c | 83 ++++++++++++++++++++++++++++++- arch/arm/mach-bcm2835/include/mach/mbox.h | 34 +++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 arch/arm/boards/raspberry-pi/env/init/ps1 diff --git a/arch/arm/boards/raspberry-pi/env/init/ps1 b/arch/arm/boards/raspberry-pi/env/init/ps1 new file mode 100644 index 0000000..f894846 --- /dev/null +++ b/arch/arm/boards/raspberry-pi/env/init/ps1 @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ ${global.allow_color} = "true" ]; then + export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m\n# " +else + export PS1="barebox@\h:\w\n# " +fi diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c index 03a16d7..ae1e92a 100644 --- a/arch/arm/boards/raspberry-pi/rpi.c +++ b/arch/arm/boards/raspberry-pi/rpi.c @@ -20,6 +20,7 @@ #include <linux/clk.h> #include <linux/clkdev.h> #include <envfs.h> +#include <malloc.h> #include <asm/armlinux.h> #include <generated/mach-types.h> @@ -38,6 +39,12 @@ struct msg_get_clock_rate { u32 end_tag; }; +struct msg_get_board_rev { + struct bcm2835_mbox_hdr hdr; + struct bcm2835_mbox_tag_get_board_rev get_board_rev; + u32 end_tag; +}; + static int rpi_get_arm_mem(u32 *size) { BCM2835_MBOX_STACK_ALIGN(struct msg_get_arm_mem, msg); @@ -79,6 +86,80 @@ static int rpi_register_clkdev(u32 clock_id, const char *name) return 0; } + +#define RPI_MODEL(_id, _name, _init) \ + [_id] = { \ + .name = _name,\ + .init = _init,\ + } +/* See comments in mbox.h for data source */ +static const struct { + const char *name; + bool has_onboard_eth; + void (*init)(void); +} models[] = { + RPI_MODEL(0, "Unknown model", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", NULL), + RPI_MODEL(BCM2835_BOARD_REV_A_7, "Model A", NULL), + RPI_MODEL(BCM2835_BOARD_REV_A_8, "Model A", NULL), + RPI_MODEL(BCM2835_BOARD_REV_A_9, "Model A", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", NULL), + RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL), + RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL), +}; + +static int rpi_board_rev = 0; + +static void rpi_get_board_rev(void) +{ + int ret; + char *name; + + BCM2835_MBOX_STACK_ALIGN(struct msg_get_board_rev, msg); + BCM2835_MBOX_INIT_HDR(msg); + BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV); + + ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); + if (ret) { + printf("bcm2835: Could not query board revision\n"); + /* Ignore error; not critical */ + return; + } + + rpi_board_rev = msg->get_board_rev.body.resp.rev; + if (rpi_board_rev >= ARRAY_SIZE(models)) { + printf("RPI: Board rev %u outside known range\n", + rpi_board_rev); + goto unknown_rev; + } + + if (!models[rpi_board_rev].name) { + printf("RPI: Board rev %u unknown\n", rpi_board_rev); + goto unknown_rev; + } + + if (!rpi_board_rev) + goto unknown_rev; + + name = asprintf("RaspberryPi %s (BCM2835/ARM1176JZF-S)", + models[rpi_board_rev].name); + barebox_set_model(name); + free(name); + + return; + +unknown_rev: + rpi_board_rev = 0; + barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); +} + static int rpi_mem_init(void) { u32 size = 0; @@ -96,7 +177,7 @@ mem_initcall(rpi_mem_init); static int rpi_console_init(void) { - barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); + rpi_get_board_rev(); barebox_set_hostname("rpi"); bcm2835_register_uart(); diff --git a/arch/arm/mach-bcm2835/include/mach/mbox.h b/arch/arm/mach-bcm2835/include/mach/mbox.h index fb8a9bf..e5f6bfa 100644 --- a/arch/arm/mach-bcm2835/include/mach/mbox.h +++ b/arch/arm/mach-bcm2835/include/mach/mbox.h @@ -124,6 +124,40 @@ struct bcm2835_mbox_tag_hdr { * }; */ +#define BCM2835_MBOX_TAG_GET_BOARD_REV 0x00010002 + +/* + * 0x2..0xf from: + * http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/ + * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=32733 + * 0x10, 0x11 from swarren's testing + */ +#define BCM2835_BOARD_REV_B_I2C0_2 0x2 +#define BCM2835_BOARD_REV_B_I2C0_3 0x3 +#define BCM2835_BOARD_REV_B_I2C1_4 0x4 +#define BCM2835_BOARD_REV_B_I2C1_5 0x5 +#define BCM2835_BOARD_REV_B_I2C1_6 0x6 +#define BCM2835_BOARD_REV_A_7 0x7 +#define BCM2835_BOARD_REV_A_8 0x8 +#define BCM2835_BOARD_REV_A_9 0x9 +#define BCM2835_BOARD_REV_B_REV2_d 0xd +#define BCM2835_BOARD_REV_B_REV2_e 0xe +#define BCM2835_BOARD_REV_B_REV2_f 0xf +#define BCM2835_BOARD_REV_B_PLUS 0x10 +#define BCM2835_BOARD_REV_CM 0x11 +#define BCM2835_BOARD_REV_A_PLUS 0x12 + +struct bcm2835_mbox_tag_get_board_rev { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + u32 rev; + } resp; + } body; +}; + #define BCM2835_MBOX_TAG_GET_ARM_MEMORY 0x00010005 struct bcm2835_mbox_tag_get_arm_mem { -- 2.1.3 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] raspberry-pi: add leds support 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-18 22:08 ` Antony Pavlov 2015-01-13 6:33 ` [PATCH 3/6] amba: pl011: add support for regulator Jean-Christophe PLAGNIOL-VILLARD ` (3 subsequent siblings) 4 siblings, 1 reply; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c index ae1e92a..81b485e 100644 --- a/arch/arm/boards/raspberry-pi/rpi.c +++ b/arch/arm/boards/raspberry-pi/rpi.c @@ -21,6 +21,8 @@ #include <linux/clkdev.h> #include <envfs.h> #include <malloc.h> +#include <gpio.h> +#include <led.h> #include <asm/armlinux.h> #include <generated/mach-types.h> @@ -87,6 +89,49 @@ static int rpi_register_clkdev(u32 clock_id, const char *name) } +static struct gpio_led leds[] = { + { + .gpio = -EINVAL, + .led = { + .name = "ACT", + }, + }, { + .gpio = -EINVAL, + .led = { + .name = "PWR", + }, + }, +}; + +static void rpi_add_led(void) +{ + int i; + struct gpio_led *l; + + for (i = 0; i < ARRAY_SIZE(leds); i++) { + l = &leds[i]; + + if (gpio_is_valid(l->gpio)) + led_gpio_register(l); + } + + l = &leds[0]; + if (gpio_is_valid(l->gpio)) + led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led); +} + +static void rpi_b_plus_init(void) +{ + leds[0].gpio = 47; + leds[1].gpio = 35; +} + +static void rpi_b_init(void) +{ + leds[0].gpio = 16; + leds[0].active_low = 1; +} + #define RPI_MODEL(_id, _name, _init) \ [_id] = { \ .name = _name,\ @@ -160,6 +205,15 @@ unknown_rev: barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); } +static void rpi_model_init(void) +{ + if (!models[rpi_board_rev].init) + return; + + models[rpi_board_rev].init(); + rpi_add_led(); +} + static int rpi_mem_init(void) { u32 size = 0; @@ -220,6 +274,7 @@ static int rpi_env_init(void) static int rpi_devices_init(void) { + rpi_model_init(); bcm2835_register_mci(); bcm2835_register_fb(); armlinux_set_architecture(MACH_TYPE_BCM2708); -- 2.1.3 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-13 6:33 ` [PATCH 2/6] raspberry-pi: add leds support Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-18 22:08 ` Antony Pavlov 2015-01-19 7:51 ` Sascha Hauer 2015-01-19 12:16 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 2 replies; 19+ messages in thread From: Antony Pavlov @ 2015-01-18 22:08 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Tue, 13 Jan 2015 07:33:06 +0100 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > --- > arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) > > diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c > index ae1e92a..81b485e 100644 > --- a/arch/arm/boards/raspberry-pi/rpi.c > +++ b/arch/arm/boards/raspberry-pi/rpi.c ... > @@ -160,6 +205,15 @@ unknown_rev: > barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); > } > > +static void rpi_model_init(void) > +{ > + if (!models[rpi_board_rev].init) > + return; Houston, we have a problem here. Please see current arch/arm/boards/raspberry-pi/rpi.c: /* See comments in mbox.h for data source */ static const struct { const char *name; bool has_onboard_eth; void (*init)(void); } models[] = { RPI_MODEL(0, "Unknown model", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", NULL), RPI_MODEL(BCM2835_BOARD_REV_A_7, "Model A", NULL), RPI_MODEL(BCM2835_BOARD_REV_A_8, "Model A", NULL), RPI_MODEL(BCM2835_BOARD_REV_A_9, "Model A", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", NULL), RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", NULL), RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL), RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL), }; All inits are NULLs! Have we any chance to run rpi_add_led()? > + > + models[rpi_board_rev].init(); > + rpi_add_led(); > +} > + > static int rpi_mem_init(void) > { > u32 size = 0; > @@ -220,6 +274,7 @@ static int rpi_env_init(void) > > static int rpi_devices_init(void) > { > + rpi_model_init(); > bcm2835_register_mci(); > bcm2835_register_fb(); > armlinux_set_architecture(MACH_TYPE_BCM2708); > -- > 2.1.3 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox -- -- Best regards, Antony Pavlov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-18 22:08 ` Antony Pavlov @ 2015-01-19 7:51 ` Sascha Hauer 2015-01-19 7:58 ` Antony Pavlov 2015-01-19 12:16 ` Jean-Christophe PLAGNIOL-VILLARD 1 sibling, 1 reply; 19+ messages in thread From: Sascha Hauer @ 2015-01-19 7:51 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox On Mon, Jan 19, 2015 at 02:08:58AM +0400, Antony Pavlov wrote: > On Tue, 13 Jan 2015 07:33:06 +0100 > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > > --- > > arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 55 insertions(+) > > > > diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c > > index ae1e92a..81b485e 100644 > > --- a/arch/arm/boards/raspberry-pi/rpi.c > > +++ b/arch/arm/boards/raspberry-pi/rpi.c > ... > > @@ -160,6 +205,15 @@ unknown_rev: > > barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); > > } > > > > +static void rpi_model_init(void) > > +{ > > + if (!models[rpi_board_rev].init) > > + return; > > Houston, we have a problem here. > Please see current arch/arm/boards/raspberry-pi/rpi.c: > > /* See comments in mbox.h for data source */ > static const struct { > const char *name; > bool has_onboard_eth; > void (*init)(void); > } models[] = { > RPI_MODEL(0, "Unknown model", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", NULL), > RPI_MODEL(BCM2835_BOARD_REV_A_7, "Model A", NULL), > RPI_MODEL(BCM2835_BOARD_REV_A_8, "Model A", NULL), > RPI_MODEL(BCM2835_BOARD_REV_A_9, "Model A", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", NULL), > RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL), > RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL), > }; > > All inits are NULLs! > > Have we any chance to run rpi_add_led()? Hm, no, this is never called. Maybe rpi_model_init() should look like this instead? static void rpi_model_init(void) { if (!models[rpi_board_rev].init) models[rpi_board_rev].init(); rpi_add_led(); } But then again, why is rpi_add_led called from rpi_model_init()? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-19 7:51 ` Sascha Hauer @ 2015-01-19 7:58 ` Antony Pavlov 2015-01-19 7:59 ` Sascha Hauer 0 siblings, 1 reply; 19+ messages in thread From: Antony Pavlov @ 2015-01-19 7:58 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox On Mon, 19 Jan 2015 08:51:44 +0100 Sascha Hauer <s.hauer@pengutronix.de> wrote: > On Mon, Jan 19, 2015 at 02:08:58AM +0400, Antony Pavlov wrote: > > On Tue, 13 Jan 2015 07:33:06 +0100 > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > > > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > > > --- > > > arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ > > > 1 file changed, 55 insertions(+) > > > > > > diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c > > > index ae1e92a..81b485e 100644 > > > --- a/arch/arm/boards/raspberry-pi/rpi.c > > > +++ b/arch/arm/boards/raspberry-pi/rpi.c > > ... > > > @@ -160,6 +205,15 @@ unknown_rev: > > > barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); > > > } > > > > > > +static void rpi_model_init(void) > > > +{ > > > + if (!models[rpi_board_rev].init) > > > + return; > > > > Houston, we have a problem here. > > Please see current arch/arm/boards/raspberry-pi/rpi.c: > > > > /* See comments in mbox.h for data source */ > > static const struct { > > const char *name; > > bool has_onboard_eth; > > void (*init)(void); > > } models[] = { > > RPI_MODEL(0, "Unknown model", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_A_7, "Model A", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_A_8, "Model A", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_A_9, "Model A", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL), > > RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL), > > }; > > > > All inits are NULLs! > > > > Have we any chance to run rpi_add_led()? > > Hm, no, this is never called. Maybe rpi_model_init() should look like > this instead? > > static void rpi_model_init(void) > { > if (!models[rpi_board_rev].init) > models[rpi_board_rev].init(); Do you really want to dereference NULL pointer? -- Best regards, Antony Pavlov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-19 7:58 ` Antony Pavlov @ 2015-01-19 7:59 ` Sascha Hauer 0 siblings, 0 replies; 19+ messages in thread From: Sascha Hauer @ 2015-01-19 7:59 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox On Mon, Jan 19, 2015 at 11:58:10AM +0400, Antony Pavlov wrote: > On Mon, 19 Jan 2015 08:51:44 +0100 > Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > On Mon, Jan 19, 2015 at 02:08:58AM +0400, Antony Pavlov wrote: > > > On Tue, 13 Jan 2015 07:33:06 +0100 > > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > > > > > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > > > > --- > > > > arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ > > > > 1 file changed, 55 insertions(+) > > > > > > > > diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c > > > > index ae1e92a..81b485e 100644 > > > > --- a/arch/arm/boards/raspberry-pi/rpi.c > > > > +++ b/arch/arm/boards/raspberry-pi/rpi.c > > > ... > > > > @@ -160,6 +205,15 @@ unknown_rev: > > > > barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); > > > > } > > > > > > > > +static void rpi_model_init(void) > > > > +{ > > > > + if (!models[rpi_board_rev].init) > > > > + return; > > > > > > Houston, we have a problem here. > > > Please see current arch/arm/boards/raspberry-pi/rpi.c: > > > > > > /* See comments in mbox.h for data source */ > > > static const struct { > > > const char *name; > > > bool has_onboard_eth; > > > void (*init)(void); > > > } models[] = { > > > RPI_MODEL(0, "Unknown model", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_A_7, "Model A", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_A_8, "Model A", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_A_9, "Model A", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL), > > > RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL), > > > }; > > > > > > All inits are NULLs! > > > > > > Have we any chance to run rpi_add_led()? > > > > Hm, no, this is never called. Maybe rpi_model_init() should look like > > this instead? > > > > static void rpi_model_init(void) > > { > > if (!models[rpi_board_rev].init) > > models[rpi_board_rev].init(); > > > Do you really want to dereference NULL pointer? Nah, drop the '!' of course. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-18 22:08 ` Antony Pavlov 2015-01-19 7:51 ` Sascha Hauer @ 2015-01-19 12:16 ` Jean-Christophe PLAGNIOL-VILLARD 1 sibling, 0 replies; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-19 12:16 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox On 02:08 Mon 19 Jan , Antony Pavlov wrote: > On Tue, 13 Jan 2015 07:33:06 +0100 > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > > --- > > arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 55 insertions(+) > > > > diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c > > index ae1e92a..81b485e 100644 > > --- a/arch/arm/boards/raspberry-pi/rpi.c > > +++ b/arch/arm/boards/raspberry-pi/rpi.c > ... > > @@ -160,6 +205,15 @@ unknown_rev: > > barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); > > } > > > > +static void rpi_model_init(void) > > +{ > > + if (!models[rpi_board_rev].init) > > + return; > > Houston, we have a problem here. > Please see current arch/arm/boards/raspberry-pi/rpi.c: > > /* See comments in mbox.h for data source */ > static const struct { > const char *name; > bool has_onboard_eth; > void (*init)(void); > } models[] = { > RPI_MODEL(0, "Unknown model", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", NULL), > RPI_MODEL(BCM2835_BOARD_REV_A_7, "Model A", NULL), > RPI_MODEL(BCM2835_BOARD_REV_A_8, "Model A", NULL), > RPI_MODEL(BCM2835_BOARD_REV_A_9, "Model A", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", NULL), > RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", NULL), > RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL), > RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL), > }; > > All inits are NULLs! > > Have we any chance to run rpi_add_led()? there is a missing patch that add the usb support so the init is not NULL so I'll send a fixup for now on that move the rpi_add_led to the init pointer Best Regards, J. > > > > + > > + models[rpi_board_rev].init(); > > + rpi_add_led(); > > +} > > + > > static int rpi_mem_init(void) > > { > > u32 size = 0; > > @@ -220,6 +274,7 @@ static int rpi_env_init(void) > > > > static int rpi_devices_init(void) > > { > > + rpi_model_init(); > > bcm2835_register_mci(); > > bcm2835_register_fb(); > > armlinux_set_architecture(MACH_TYPE_BCM2708); > > -- > > 2.1.3 > > > > > > _______________________________________________ > > barebox mailing list > > barebox@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/barebox > > > -- > -- > Best regards, > Antony Pavlov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 3/6] amba: pl011: add support for regulator 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 2/6] raspberry-pi: add leds support Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 4/6] driver: add postcore_platform_driver Jean-Christophe PLAGNIOL-VILLARD ` (2 subsequent siblings) 4 siblings, 0 replies; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- drivers/serial/amba-pl011.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index fc7723e..4c4067d 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -28,6 +28,7 @@ #include <init.h> #include <malloc.h> #include <io.h> +#include <regulator.h> #include <linux/amba/serial.h> #include <linux/clk.h> #include <linux/err.h> @@ -181,6 +182,16 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) { struct amba_uart_port *uart; struct console_device *cdev; + struct regulator *r; + + r = regulator_get(&dev->dev, NULL); + if (r) { + int ret; + + ret = regulator_enable(r); + if (ret) + return ret; + } uart = xzalloc(sizeof(struct amba_uart_port)); uart->clk = clk_get(&dev->dev, NULL); -- 2.1.3 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 4/6] driver: add postcore_platform_driver 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 2/6] raspberry-pi: add leds support Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 3/6] amba: pl011: add support for regulator Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 5/6] regulator: allow to use it with non DT device Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 6/6] regulator: add bcm2835 driver Jean-Christophe PLAGNIOL-VILLARD 4 siblings, 0 replies; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- include/driver.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/driver.h b/include/driver.h index 46aae4f..76fd4b1 100644 --- a/include/driver.h +++ b/include/driver.h @@ -409,6 +409,8 @@ int platform_driver_register(struct driver_d *drv); } \ level##_initcall(drv##_register) +#define postcore_platform_driver(drv) \ + register_driver_macro(postcore,platform,drv) #define coredevice_platform_driver(drv) \ register_driver_macro(coredevice,platform,drv) #define device_platform_driver(drv) \ -- 2.1.3 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 5/6] regulator: allow to use it with non DT device 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD ` (2 preceding siblings ...) 2015-01-13 6:33 ` [PATCH 4/6] driver: add postcore_platform_driver Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 6/6] regulator: add bcm2835 driver Jean-Christophe PLAGNIOL-VILLARD 4 siblings, 0 replies; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 UTC (permalink / raw) To: barebox this will use the device name as regulator name with the same Algo as clkdev for lookup Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- drivers/regulator/Kconfig | 2 +- drivers/regulator/core.c | 98 +++++++++++++++++++++++++++++++++++++++-------- include/regulator.h | 10 +++++ 3 files changed, 93 insertions(+), 17 deletions(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 493b18a..4085b3f 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1,5 +1,4 @@ menuconfig REGULATOR - depends on OFDEVICE bool "voltage regulator support" if REGULATOR @@ -7,6 +6,7 @@ if REGULATOR config REGULATOR_FIXED bool "fixed/gpio regulator" depends on GENERIC_GPIO + depends on OFDEVICE help This enables a simple fixed regulator. It is used for regulators which are not software controllable or controllable via gpio. diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2808c27..a3c9e41 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -33,6 +33,7 @@ struct regulator_internal { int min_uv; int max_uv; char *name; + const char *supply; struct list_head consumer_list; }; @@ -42,6 +43,25 @@ struct regulator { struct device_d *dev; }; +static struct regulator_internal * __regulator_register(struct regulator_dev *rd, const char *name) +{ + struct regulator_internal *ri; + + ri = xzalloc(sizeof(*ri)); + ri->rdev = rd; + + INIT_LIST_HEAD(&ri->consumer_list); + + list_add_tail(&ri->list, ®ulator_list); + + if (name) + ri->name = xstrdup(name); + + return ri; +} + + +#ifdef CONFIG_OFDEVICE /* * of_regulator_register - register a regulator corresponding to a device_node * @rd: the regulator device providing the ops @@ -54,18 +74,10 @@ int of_regulator_register(struct regulator_dev *rd, struct device_node *node) struct regulator_internal *ri; const char *name; - ri = xzalloc(sizeof(*ri)); - ri->rdev = rd; - ri->node = node; - - INIT_LIST_HEAD(&ri->consumer_list); - - list_add_tail(&ri->list, ®ulator_list); - name = of_get_property(node, "regulator-name", NULL); - if (name) - ri->name = xstrdup(name); + ri = __regulator_register(rd, name); + ri->node = node; of_property_read_u32(node, "regulator-enable-ramp-delay", &ri->enable_time_us); @@ -127,6 +139,55 @@ out: return ri; } +#else +static struct regulator_internal *of_regulator_get(struct device_d *dev, const char *supply) +{ + return NULL; +} +#endif + +int dev_regulator_register(struct regulator_dev *rd, const char * name, const char* supply) +{ + struct regulator_internal *ri; + + ri = __regulator_register(rd, name); + + ri->supply = supply; + + return 0; +} + +static struct regulator_internal *dev_regulator_get(struct device_d *dev, const char *supply) +{ + struct regulator_internal *ri; + struct regulator_internal *ret = NULL; + int match, best = 0; + const char *dev_id = dev ? dev_name(dev) : NULL; + + list_for_each_entry(ri, ®ulator_list, list) { + match = 0; + if (ri->name) { + if (!dev_id || strcmp(ri->name, dev_id)) + continue; + match += 2; + } + if (ri->supply) { + if (!supply || strcmp(ri->supply, supply)) + continue; + match += 1; + } + + if (match > best) { + ret = ri; + if (match != 3) + best = match; + else + break; + } + } + + return ret; +} /* * regulator_get - get the supply for a device. @@ -140,15 +201,20 @@ out: */ struct regulator *regulator_get(struct device_d *dev, const char *supply) { - struct regulator_internal *ri; + struct regulator_internal *ri = NULL; struct regulator *r; - if (!dev->device_node) - return NULL; + if (dev->device_node) { + ri = of_regulator_get(dev, supply); + if (IS_ERR(ri)) + return ERR_CAST(ri); + } - ri = of_regulator_get(dev, supply); - if (IS_ERR(ri)) - return ERR_CAST(ri); + if (!ri) { + ri = dev_regulator_get(dev, supply); + if (IS_ERR(ri)) + return ERR_CAST(ri); + } if (!ri) return NULL; diff --git a/include/regulator.h b/include/regulator.h index 26a5e56..a43d3df 100644 --- a/include/regulator.h +++ b/include/regulator.h @@ -15,7 +15,17 @@ struct regulator_ops { int (*is_enabled) (struct regulator_dev *); }; +#ifdef CONFIG_OFDEVICE int of_regulator_register(struct regulator_dev *rd, struct device_node *node); +#else +static inline int of_regulator_register(struct regulator_dev *rd, + struct device_node *node) +{ + return -ENOSYS; +} +#endif +int dev_regulator_register(struct regulator_dev *rd, const char * name, + const char* supply); void regulators_print(void); -- 2.1.3 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 6/6] regulator: add bcm2835 driver 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD ` (3 preceding siblings ...) 2015-01-13 6:33 ` [PATCH 5/6] regulator: allow to use it with non DT device Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 ` Jean-Christophe PLAGNIOL-VILLARD 4 siblings, 0 replies; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:33 UTC (permalink / raw) To: barebox this will allow to handle IP power automatically and not at board level Mainline kernel need this as they do not have the regulator driver support as some IP such as USB are not power on at boot Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/mach-bcm2835/include/mach/mbox.h | 49 ++++++++++ drivers/regulator/Kconfig | 5 + drivers/regulator/Makefile | 1 + drivers/regulator/bcm2835.c | 149 ++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+) create mode 100644 drivers/regulator/bcm2835.c diff --git a/arch/arm/mach-bcm2835/include/mach/mbox.h b/arch/arm/mach-bcm2835/include/mach/mbox.h index e5f6bfa..d991ba7 100644 --- a/arch/arm/mach-bcm2835/include/mach/mbox.h +++ b/arch/arm/mach-bcm2835/include/mach/mbox.h @@ -172,6 +172,55 @@ struct bcm2835_mbox_tag_get_arm_mem { } body; }; +#define BCM2835_MBOX_POWER_DEVID_SDHCI 0 +#define BCM2835_MBOX_POWER_DEVID_UART0 1 +#define BCM2835_MBOX_POWER_DEVID_UART1 2 +#define BCM2835_MBOX_POWER_DEVID_USB_HCD 3 +#define BCM2835_MBOX_POWER_DEVID_I2C0 4 +#define BCM2835_MBOX_POWER_DEVID_I2C1 5 +#define BCM2835_MBOX_POWER_DEVID_I2C2 6 +#define BCM2835_MBOX_POWER_DEVID_SPI 7 +#define BCM2835_MBOX_POWER_DEVID_CCP2TX 8 + +#define BCM2835_MBOX_POWER_STATE_RESP_ON (1 << 0) +/* Device doesn't exist */ +#define BCM2835_MBOX_POWER_STATE_RESP_NODEV (1 << 1) + +#define BCM2835_MBOX_TAG_GET_POWER_STATE 0x00020001 + +struct bcm2835_mbox_tag_get_power_state { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + u32 device_id; + } req; + struct { + u32 device_id; + u32 state; + } resp; + } body; +}; + +#define BCM2835_MBOX_TAG_SET_POWER_STATE 0x00028001 + +#define BCM2835_MBOX_SET_POWER_STATE_REQ_OFF (0 << 0) +#define BCM2835_MBOX_SET_POWER_STATE_REQ_ON (1 << 0) +#define BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT (1 << 1) + +struct bcm2835_mbox_tag_set_power_state { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + u32 device_id; + u32 state; + } req; + struct { + u32 device_id; + u32 state; + } resp; + } body; +}; + #define BCM2835_MBOX_TAG_GET_CLOCK_RATE 0x00030002 #define BCM2835_MBOX_CLOCK_ID_EMMC 1 diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 4085b3f..05c3f48 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -11,4 +11,9 @@ config REGULATOR_FIXED This enables a simple fixed regulator. It is used for regulators which are not software controllable or controllable via gpio. +config REGULATOR_BCM2835 + bool + depends on ARCH_BCM2835 + default y + endif diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 65e65d8..d663c16 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_REGULATOR) += core.o obj-$(CONFIG_REGULATOR_FIXED) += fixed.o +obj-$(CONFIG_REGULATOR_BCM2835) += bcm2835.o diff --git a/drivers/regulator/bcm2835.c b/drivers/regulator/bcm2835.c new file mode 100644 index 0000000..5195210 --- /dev/null +++ b/drivers/regulator/bcm2835.c @@ -0,0 +1,149 @@ +/* + * bcm2835 regulator support + * + * Copyright (c) 2015 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * GPLv2 Only + */ +#include <common.h> +#include <malloc.h> +#include <init.h> +#include <regulator.h> + +#include <mach/mbox.h> + +#define REG_DEV(_id, _name) \ + { \ + .id = _id, \ + .devname = _name,\ + } + +static struct regulator_bcm2835 { + int id; + char *devname; + + struct device_d *dev; + struct regulator_dev rdev; +} regs[] = { + REG_DEV(BCM2835_MBOX_POWER_DEVID_SDHCI, "bcm2835_mci0"), + REG_DEV(BCM2835_MBOX_POWER_DEVID_UART0, "uart0-pl0110"), + REG_DEV(BCM2835_MBOX_POWER_DEVID_UART1, "uart0-pl0111"), + REG_DEV(BCM2835_MBOX_POWER_DEVID_USB_HCD, "bcm2835_usb"), + REG_DEV(BCM2835_MBOX_POWER_DEVID_I2C0, "bcm2835_i2c0"), + REG_DEV(BCM2835_MBOX_POWER_DEVID_I2C1, "bcm2835_i2c1"), + REG_DEV(BCM2835_MBOX_POWER_DEVID_I2C2, "bcm2835_i2c2"), + REG_DEV(BCM2835_MBOX_POWER_DEVID_SPI, "bcm2835_spi"), + REG_DEV(BCM2835_MBOX_POWER_DEVID_CCP2TX, "bcm2835_ccp2tx"), +}; + +struct msg_set_power_state { + struct bcm2835_mbox_hdr hdr; + struct bcm2835_mbox_tag_set_power_state set_power_state; + u32 end_tag; +}; + +static int regulator_bcm2835_set(struct regulator_bcm2835 *rb, int state) +{ + BCM2835_MBOX_STACK_ALIGN(struct msg_set_power_state, msg_pwr); + int ret; + + BCM2835_MBOX_INIT_HDR(msg_pwr); + BCM2835_MBOX_INIT_TAG(&msg_pwr->set_power_state, + SET_POWER_STATE); + msg_pwr->set_power_state.body.req.device_id = rb->id; + msg_pwr->set_power_state.body.req.state = + state | + BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT; + + ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, + &msg_pwr->hdr); + if (ret) { + dev_err(rb->dev ,"bcm2835: Could not set module %u power state\n", + rb->id); + return ret; + } + + return 0; +} + +static int regulator_bcm2835_enable(struct regulator_dev *rdev) +{ + struct regulator_bcm2835 *rb = container_of(rdev, struct regulator_bcm2835, rdev); + + return regulator_bcm2835_set(rb, BCM2835_MBOX_SET_POWER_STATE_REQ_ON); +} + +static int regulator_bcm2835_disable(struct regulator_dev *rdev) +{ + struct regulator_bcm2835 *rb = container_of(rdev, struct regulator_bcm2835, rdev); + + return regulator_bcm2835_set(rb, BCM2835_MBOX_SET_POWER_STATE_REQ_OFF); +} + +struct msg_get_power_state { + struct bcm2835_mbox_hdr hdr; + struct bcm2835_mbox_tag_get_power_state get_power_state; + u32 end_tag; +}; + +static int regulator_bcm2835_is_enabled(struct regulator_dev *rdev) +{ + struct regulator_bcm2835 *rb = container_of(rdev, struct regulator_bcm2835, rdev); + BCM2835_MBOX_STACK_ALIGN(struct msg_get_power_state, msg_pwr); + int ret; + + BCM2835_MBOX_INIT_HDR(msg_pwr); + BCM2835_MBOX_INIT_TAG(&msg_pwr->get_power_state, + GET_POWER_STATE); + msg_pwr->get_power_state.body.req.device_id = rb->id; + + ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, + &msg_pwr->hdr); + if (ret) { + dev_err(rb->dev ,"bcm2835: Could not get module %u power state\n", + rb->id); + return ret; + } + + return msg_pwr->get_power_state.body.resp.state; +} + +static struct regulator_ops bcm2835_ops = { + .enable = regulator_bcm2835_enable, + .disable = regulator_bcm2835_disable, + .is_enabled = regulator_bcm2835_is_enabled, +}; + +static int regulator_bcm2835_probe(struct device_d *dev) +{ + struct regulator_bcm2835 *rb; + int ret, i; + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + rb = ®s[i]; + + rb->rdev.ops = &bcm2835_ops; + rb->dev = dev; + + ret = dev_regulator_register(&rb->rdev, rb->devname, NULL); + if (ret) + return ret; + } + + return 0; +} + +static struct driver_d regulator_bcm2835_driver = { + .name = "regulator-bcm2835", + .probe = regulator_bcm2835_probe, +}; +postcore_platform_driver(regulator_bcm2835_driver); + +static int regulator_bcm2835_init(void) +{ + add_generic_device("regulator-bcm2835", DEVICE_ID_SINGLE, NULL, + 0, 0, 0, NULL); + + return 0; +} +postcore_initcall(regulator_bcm2835_init); -- 2.1.3 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/6 v2] raspberry-pi: updates 2015-01-13 6:31 [PATCH 0/6 v2] raspberry-pi: updates Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-14 6:24 ` Sascha Hauer 2015-01-18 22:20 ` Antony Pavlov 2 siblings, 0 replies; 19+ messages in thread From: Sascha Hauer @ 2015-01-14 6:24 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Tue, Jan 13, 2015 at 07:31:28AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote: > Hi, > > v2: > > send correct leds patch > > The following patch serie prepare the raspberry for USB support > > The following changes since commit 9cd14d260aa22ae089f81a07be2c0e5dea2ffc94: > > Merge branch 'for-next/pbl-console' (2015-01-09 17:38:27 +0100) > > are available in the git repository at: > > git://git.jcrosoft.org/barebox.git delivery/rpi > > for you to fetch changes up to 70d2d564af770d99c0e8a4fbfa314e6d55d58629: > > regulator: add bcm2835 driver (2015-01-11 19:04:06 +0800) Applied, thanks Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/6 v2] raspberry-pi: updates 2015-01-13 6:31 [PATCH 0/6 v2] raspberry-pi: updates Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD 2015-01-14 6:24 ` [PATCH 0/6 v2] raspberry-pi: updates Sascha Hauer @ 2015-01-18 22:20 ` Antony Pavlov 2 siblings, 0 replies; 19+ messages in thread From: Antony Pavlov @ 2015-01-18 22:20 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Tue, 13 Jan 2015 07:31:28 +0100 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > Hi, > > v2: > > send correct leds patch IMHO we have to enable LED stuff in rpi_defconfig. > The following patch serie prepare the raspberry for USB support > > The following changes since commit 9cd14d260aa22ae089f81a07be2c0e5dea2ffc94: > > Merge branch 'for-next/pbl-console' (2015-01-09 17:38:27 +0100) > > are available in the git repository at: > > git://git.jcrosoft.org/barebox.git delivery/rpi > > for you to fetch changes up to 70d2d564af770d99c0e8a4fbfa314e6d55d58629: > > regulator: add bcm2835 driver (2015-01-11 19:04:06 +0800) > > ---------------------------------------------------------------- > Jean-Christophe PLAGNIOL-VILLARD (6): > raspberry-pi: add board model detection > raspberry-pi: add leds support > amba: pl011: add support for regulator > driver: add postcore_platform_driver > regulator: allow to use it with non DT device > regulator: add bcm2835 driver > > arch/arm/boards/raspberry-pi/env/init/ps1 | 7 +++++++ > arch/arm/boards/raspberry-pi/rpi.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > arch/arm/mach-bcm2835/include/mach/mbox.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > drivers/regulator/Kconfig | 7 ++++++- > drivers/regulator/Makefile | 1 + > drivers/regulator/bcm2835.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > drivers/regulator/core.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------- > drivers/serial/amba-pl011.c | 11 +++++++++++ > include/driver.h | 2 ++ > include/regulator.h | 10 ++++++++++ > 10 files changed, 488 insertions(+), 18 deletions(-) > create mode 100644 arch/arm/boards/raspberry-pi/env/init/ps1 > create mode 100644 drivers/regulator/bcm2835.c > > Best Regards, > J. > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox -- -- Best regards, Antony Pavlov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 0/6] raspberry-pi: updates @ 2015-01-13 6:24 Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:26 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:24 UTC (permalink / raw) To: barebox Hi, The following patch serie prepare the raspberry for USB support The following changes since commit 9cd14d260aa22ae089f81a07be2c0e5dea2ffc94: Merge branch 'for-next/pbl-console' (2015-01-09 17:38:27 +0100) are available in the git repository at: git://git.jcrosoft.org/barebox.git delivery/rpi for you to fetch changes up to eebb138c29d100ced23dd7ffc6cd3f0c0a6930be: regulator: add bcm2835 driver (2015-01-11 18:17:39 +0800) ---------------------------------------------------------------- Jean-Christophe PLAGNIOL-VILLARD (6): raspberry-pi: add board model detection raspberry-pi: add leds support amba: pl011: add support for regulator driver: add postcore_platform_driver regulator: allow to use it with non DT device regulator: add bcm2835 driver arch/arm/boards/raspberry-pi/env/init/ps1 | 7 +++++++ arch/arm/boards/raspberry-pi/rpi.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- arch/arm/mach-bcm2835/include/mach/mbox.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/regulator/Kconfig | 7 ++++++- drivers/regulator/Makefile | 1 + drivers/regulator/bcm2835.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/regulator/core.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------- drivers/serial/amba-pl011.c | 11 +++++++++++ include/driver.h | 2 ++ include/regulator.h | 10 ++++++++++ 10 files changed, 488 insertions(+), 18 deletions(-) create mode 100644 arch/arm/boards/raspberry-pi/env/init/ps1 create mode 100644 drivers/regulator/bcm2835.c Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/6] raspberry-pi: add board model detection 2015-01-13 6:24 [PATCH 0/6] " Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:26 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:26 ` [PATCH 2/6] raspberry-pi: add leds support Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:26 UTC (permalink / raw) To: barebox as the name is very long, return ps1 to the next line Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/boards/raspberry-pi/env/init/ps1 | 7 +++ arch/arm/boards/raspberry-pi/rpi.c | 83 ++++++++++++++++++++++++++++++- arch/arm/mach-bcm2835/include/mach/mbox.h | 34 +++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 arch/arm/boards/raspberry-pi/env/init/ps1 diff --git a/arch/arm/boards/raspberry-pi/env/init/ps1 b/arch/arm/boards/raspberry-pi/env/init/ps1 new file mode 100644 index 0000000..f894846 --- /dev/null +++ b/arch/arm/boards/raspberry-pi/env/init/ps1 @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ ${global.allow_color} = "true" ]; then + export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m\n# " +else + export PS1="barebox@\h:\w\n# " +fi diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c index 03a16d7..ae1e92a 100644 --- a/arch/arm/boards/raspberry-pi/rpi.c +++ b/arch/arm/boards/raspberry-pi/rpi.c @@ -20,6 +20,7 @@ #include <linux/clk.h> #include <linux/clkdev.h> #include <envfs.h> +#include <malloc.h> #include <asm/armlinux.h> #include <generated/mach-types.h> @@ -38,6 +39,12 @@ struct msg_get_clock_rate { u32 end_tag; }; +struct msg_get_board_rev { + struct bcm2835_mbox_hdr hdr; + struct bcm2835_mbox_tag_get_board_rev get_board_rev; + u32 end_tag; +}; + static int rpi_get_arm_mem(u32 *size) { BCM2835_MBOX_STACK_ALIGN(struct msg_get_arm_mem, msg); @@ -79,6 +86,80 @@ static int rpi_register_clkdev(u32 clock_id, const char *name) return 0; } + +#define RPI_MODEL(_id, _name, _init) \ + [_id] = { \ + .name = _name,\ + .init = _init,\ + } +/* See comments in mbox.h for data source */ +static const struct { + const char *name; + bool has_onboard_eth; + void (*init)(void); +} models[] = { + RPI_MODEL(0, "Unknown model", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_4, "Model B", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_5, "Model B", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_I2C1_6, "Model B", NULL), + RPI_MODEL(BCM2835_BOARD_REV_A_7, "Model A", NULL), + RPI_MODEL(BCM2835_BOARD_REV_A_8, "Model A", NULL), + RPI_MODEL(BCM2835_BOARD_REV_A_9, "Model A", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_REV2_d, "Model B rev2", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_REV2_e, "Model B rev2", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_REV2_f, "Model B rev2", NULL), + RPI_MODEL(BCM2835_BOARD_REV_B_PLUS, "Model B+", NULL), + RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL), + RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL), +}; + +static int rpi_board_rev = 0; + +static void rpi_get_board_rev(void) +{ + int ret; + char *name; + + BCM2835_MBOX_STACK_ALIGN(struct msg_get_board_rev, msg); + BCM2835_MBOX_INIT_HDR(msg); + BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV); + + ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); + if (ret) { + printf("bcm2835: Could not query board revision\n"); + /* Ignore error; not critical */ + return; + } + + rpi_board_rev = msg->get_board_rev.body.resp.rev; + if (rpi_board_rev >= ARRAY_SIZE(models)) { + printf("RPI: Board rev %u outside known range\n", + rpi_board_rev); + goto unknown_rev; + } + + if (!models[rpi_board_rev].name) { + printf("RPI: Board rev %u unknown\n", rpi_board_rev); + goto unknown_rev; + } + + if (!rpi_board_rev) + goto unknown_rev; + + name = asprintf("RaspberryPi %s (BCM2835/ARM1176JZF-S)", + models[rpi_board_rev].name); + barebox_set_model(name); + free(name); + + return; + +unknown_rev: + rpi_board_rev = 0; + barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); +} + static int rpi_mem_init(void) { u32 size = 0; @@ -96,7 +177,7 @@ mem_initcall(rpi_mem_init); static int rpi_console_init(void) { - barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); + rpi_get_board_rev(); barebox_set_hostname("rpi"); bcm2835_register_uart(); diff --git a/arch/arm/mach-bcm2835/include/mach/mbox.h b/arch/arm/mach-bcm2835/include/mach/mbox.h index fb8a9bf..e5f6bfa 100644 --- a/arch/arm/mach-bcm2835/include/mach/mbox.h +++ b/arch/arm/mach-bcm2835/include/mach/mbox.h @@ -124,6 +124,40 @@ struct bcm2835_mbox_tag_hdr { * }; */ +#define BCM2835_MBOX_TAG_GET_BOARD_REV 0x00010002 + +/* + * 0x2..0xf from: + * http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/ + * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=32733 + * 0x10, 0x11 from swarren's testing + */ +#define BCM2835_BOARD_REV_B_I2C0_2 0x2 +#define BCM2835_BOARD_REV_B_I2C0_3 0x3 +#define BCM2835_BOARD_REV_B_I2C1_4 0x4 +#define BCM2835_BOARD_REV_B_I2C1_5 0x5 +#define BCM2835_BOARD_REV_B_I2C1_6 0x6 +#define BCM2835_BOARD_REV_A_7 0x7 +#define BCM2835_BOARD_REV_A_8 0x8 +#define BCM2835_BOARD_REV_A_9 0x9 +#define BCM2835_BOARD_REV_B_REV2_d 0xd +#define BCM2835_BOARD_REV_B_REV2_e 0xe +#define BCM2835_BOARD_REV_B_REV2_f 0xf +#define BCM2835_BOARD_REV_B_PLUS 0x10 +#define BCM2835_BOARD_REV_CM 0x11 +#define BCM2835_BOARD_REV_A_PLUS 0x12 + +struct bcm2835_mbox_tag_get_board_rev { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + u32 rev; + } resp; + } body; +}; + #define BCM2835_MBOX_TAG_GET_ARM_MEMORY 0x00010005 struct bcm2835_mbox_tag_get_arm_mem { -- 2.1.3 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/6] raspberry-pi: add leds support 2015-01-13 6:26 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:26 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 7:58 ` Antony Pavlov 0 siblings, 1 reply; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 6:26 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c index ae1e92a..7d866cc 100644 --- a/arch/arm/boards/raspberry-pi/rpi.c +++ b/arch/arm/boards/raspberry-pi/rpi.c @@ -21,6 +21,8 @@ #include <linux/clkdev.h> #include <envfs.h> #include <malloc.h> +#include <gpio.h> +#include <led.h> #include <asm/armlinux.h> #include <generated/mach-types.h> @@ -87,6 +89,49 @@ static int rpi_register_clkdev(u32 clock_id, const char *name) } +static struct gpio_led leds[] = { + { + .gpio = -EINVAL, + .led = { + .name = "ACT", + }, + }, { + .gpio = -EINVAL, + .led = { + .name = "PWR", + }, + }, +}; + +static void rpi_add_led(void) +{ + int i; + struct gpio_led *l; + + for (i = 0; i < ARRAY_SIZE(leds); i++) { + l = &leds[i]; + + if (gpio_is_valid(l->gpio)) + led_gpio_register(l); + } + + l = &leds[0]; + if (gpio_is_valid(l->gpio)) + led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led); +} + +static void rpi_b_plus_init(void) +{ + leds[0].gpio = 47; + leds[1].gpio = 35; +} + +static void rpi_b_init(void) +{ + leds[0].gpio = 16; + leds[0].active_low = 1; +} + #define RPI_MODEL(_id, _name, _init) \ [_id] = { \ .name = _name,\ @@ -160,6 +205,15 @@ unknown_rev: barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); } +static void rpi_model_init(void) +{ + rpi_set_usbethaddr(); + if (models[rpi_board_rev].init) { + models[rpi_board_rev].init(); + rpi_add_led(); + } +} + static int rpi_mem_init(void) { u32 size = 0; @@ -220,6 +274,7 @@ static int rpi_env_init(void) static int rpi_devices_init(void) { + rpi_model_init(); bcm2835_register_mci(); bcm2835_register_fb(); armlinux_set_architecture(MACH_TYPE_BCM2708); -- 2.1.3 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-13 6:26 ` [PATCH 2/6] raspberry-pi: add leds support Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 7:58 ` Antony Pavlov 2015-01-13 8:15 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 19+ messages in thread From: Antony Pavlov @ 2015-01-13 7:58 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Tue, 13 Jan 2015 07:26:12 +0100 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: I have planned to switch raspberry pi to device tree support as Linux does. IMHO POWER LED is not GPIO controlable, please see these schematics http://www.raspberrypi.org/wp-content/uploads/2012/04/Raspberry-Pi-Schematics-R1.0.pdf http://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/Raspberry-Pi-B-Plus-V1.2-Schematics.pdf > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > --- > arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) > > diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c > index ae1e92a..7d866cc 100644 > --- a/arch/arm/boards/raspberry-pi/rpi.c > +++ b/arch/arm/boards/raspberry-pi/rpi.c > @@ -21,6 +21,8 @@ > #include <linux/clkdev.h> > #include <envfs.h> > #include <malloc.h> > +#include <gpio.h> > +#include <led.h> > #include <asm/armlinux.h> > #include <generated/mach-types.h> > > @@ -87,6 +89,49 @@ static int rpi_register_clkdev(u32 clock_id, const char *name) > } > > > +static struct gpio_led leds[] = { > + { > + .gpio = -EINVAL, > + .led = { > + .name = "ACT", > + }, > + }, { > + .gpio = -EINVAL, > + .led = { > + .name = "PWR", > + }, > + }, > +}; > + > +static void rpi_add_led(void) > +{ > + int i; > + struct gpio_led *l; > + > + for (i = 0; i < ARRAY_SIZE(leds); i++) { > + l = &leds[i]; > + > + if (gpio_is_valid(l->gpio)) > + led_gpio_register(l); > + } > + > + l = &leds[0]; > + if (gpio_is_valid(l->gpio)) > + led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led); > +} > + > +static void rpi_b_plus_init(void) > +{ > + leds[0].gpio = 47; > + leds[1].gpio = 35; > +} > + > +static void rpi_b_init(void) > +{ > + leds[0].gpio = 16; > + leds[0].active_low = 1; > +} > + > #define RPI_MODEL(_id, _name, _init) \ > [_id] = { \ > .name = _name,\ > @@ -160,6 +205,15 @@ unknown_rev: > barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); > } > > +static void rpi_model_init(void) > +{ > + rpi_set_usbethaddr(); > + if (models[rpi_board_rev].init) { > + models[rpi_board_rev].init(); > + rpi_add_led(); > + } > +} > + > static int rpi_mem_init(void) > { > u32 size = 0; > @@ -220,6 +274,7 @@ static int rpi_env_init(void) > > static int rpi_devices_init(void) > { > + rpi_model_init(); > bcm2835_register_mci(); > bcm2835_register_fb(); > armlinux_set_architecture(MACH_TYPE_BCM2708); > -- > 2.1.3 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox -- -- Best regards, Antony Pavlov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-13 7:58 ` Antony Pavlov @ 2015-01-13 8:15 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 10:11 ` Antony Pavlov 0 siblings, 1 reply; 19+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 8:15 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox > On Jan 13, 2015, at 3:58 PM, Antony Pavlov <antonynpavlov@gmail.com> wrote: > > On Tue, 13 Jan 2015 07:26:12 +0100 > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > I have planned to switch raspberry pi to device tree support as Linux does. but as I do not want to build multi binary switch (leds & co) those to DT make no sense except if we can chose the DT at runtime > > IMHO POWER LED is not GPIO controlable, please see these schematics yes it is does, I have a B+ and it’s controllable Best Regards, J. > > http://www.raspberrypi.org/wp-content/uploads/2012/04/Raspberry-Pi-Schematics-R1.0.pdf > http://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/Raspberry-Pi-B-Plus-V1.2-Schematics.pdf > > >> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> >> --- >> arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 55 insertions(+) >> >> diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c >> index ae1e92a..7d866cc 100644 >> --- a/arch/arm/boards/raspberry-pi/rpi.c >> +++ b/arch/arm/boards/raspberry-pi/rpi.c >> @@ -21,6 +21,8 @@ >> #include <linux/clkdev.h> >> #include <envfs.h> >> #include <malloc.h> >> +#include <gpio.h> >> +#include <led.h> >> #include <asm/armlinux.h> >> #include <generated/mach-types.h> >> >> @@ -87,6 +89,49 @@ static int rpi_register_clkdev(u32 clock_id, const char *name) >> } >> >> >> +static struct gpio_led leds[] = { >> + { >> + .gpio = -EINVAL, >> + .led = { >> + .name = "ACT", >> + }, >> + }, { >> + .gpio = -EINVAL, >> + .led = { >> + .name = "PWR", >> + }, >> + }, >> +}; >> + >> +static void rpi_add_led(void) >> +{ >> + int i; >> + struct gpio_led *l; >> + >> + for (i = 0; i < ARRAY_SIZE(leds); i++) { >> + l = &leds[i]; >> + >> + if (gpio_is_valid(l->gpio)) >> + led_gpio_register(l); >> + } >> + >> + l = &leds[0]; >> + if (gpio_is_valid(l->gpio)) >> + led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led); >> +} >> + >> +static void rpi_b_plus_init(void) >> +{ >> + leds[0].gpio = 47; >> + leds[1].gpio = 35; >> +} >> + >> +static void rpi_b_init(void) >> +{ >> + leds[0].gpio = 16; >> + leds[0].active_low = 1; >> +} >> + >> #define RPI_MODEL(_id, _name, _init) \ >> [_id] = { \ >> .name = _name,\ >> @@ -160,6 +205,15 @@ unknown_rev: >> barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); >> } >> >> +static void rpi_model_init(void) >> +{ >> + rpi_set_usbethaddr(); >> + if (models[rpi_board_rev].init) { >> + models[rpi_board_rev].init(); >> + rpi_add_led(); >> + } >> +} >> + >> static int rpi_mem_init(void) >> { >> u32 size = 0; >> @@ -220,6 +274,7 @@ static int rpi_env_init(void) >> >> static int rpi_devices_init(void) >> { >> + rpi_model_init(); >> bcm2835_register_mci(); >> bcm2835_register_fb(); >> armlinux_set_architecture(MACH_TYPE_BCM2708); >> -- >> 2.1.3 >> >> >> _______________________________________________ >> barebox mailing list >> barebox@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/barebox > > > -- > -- > Best regards, > Antony Pavlov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-13 8:15 ` Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-13 10:11 ` Antony Pavlov 2015-01-14 6:26 ` Sascha Hauer 0 siblings, 1 reply; 19+ messages in thread From: Antony Pavlov @ 2015-01-13 10:11 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Tue, 13 Jan 2015 16:15:45 +0800 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > > On Jan 13, 2015, at 3:58 PM, Antony Pavlov <antonynpavlov@gmail.com> wrote: > > > > On Tue, 13 Jan 2015 07:26:12 +0100 > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > > > I have planned to switch raspberry pi to device tree support as Linux does. > > but as I do not want to build multi binary switch (leds & co) those to DT make no sense except if we can > chose the DT at runtime > > > > > IMHO POWER LED is not GPIO controlable, please see these schematics > > yes it is does, I have a B+ and it’s controllable I'll check your series on my B+ in a few days. > > http://www.raspberrypi.org/wp-content/uploads/2012/04/Raspberry-Pi-Schematics-R1.0.pdf > > http://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/Raspberry-Pi-B-Plus-V1.2-Schematics.pdf > > > > > >> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > >> --- > >> arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++ > >> 1 file changed, 55 insertions(+) > >> > >> diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c > >> index ae1e92a..7d866cc 100644 > >> --- a/arch/arm/boards/raspberry-pi/rpi.c > >> +++ b/arch/arm/boards/raspberry-pi/rpi.c > >> @@ -21,6 +21,8 @@ > >> #include <linux/clkdev.h> > >> #include <envfs.h> > >> #include <malloc.h> > >> +#include <gpio.h> > >> +#include <led.h> > >> #include <asm/armlinux.h> > >> #include <generated/mach-types.h> > >> > >> @@ -87,6 +89,49 @@ static int rpi_register_clkdev(u32 clock_id, const char *name) > >> } > >> > >> > >> +static struct gpio_led leds[] = { > >> + { > >> + .gpio = -EINVAL, > >> + .led = { > >> + .name = "ACT", > >> + }, > >> + }, { > >> + .gpio = -EINVAL, > >> + .led = { > >> + .name = "PWR", > >> + }, > >> + }, > >> +}; > >> + > >> +static void rpi_add_led(void) > >> +{ > >> + int i; > >> + struct gpio_led *l; > >> + > >> + for (i = 0; i < ARRAY_SIZE(leds); i++) { > >> + l = &leds[i]; > >> + > >> + if (gpio_is_valid(l->gpio)) > >> + led_gpio_register(l); > >> + } > >> + > >> + l = &leds[0]; > >> + if (gpio_is_valid(l->gpio)) > >> + led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led); > >> +} > >> + > >> +static void rpi_b_plus_init(void) > >> +{ > >> + leds[0].gpio = 47; > >> + leds[1].gpio = 35; > >> +} > >> + > >> +static void rpi_b_init(void) > >> +{ > >> + leds[0].gpio = 16; > >> + leds[0].active_low = 1; > >> +} > >> + > >> #define RPI_MODEL(_id, _name, _init) \ > >> [_id] = { \ > >> .name = _name,\ > >> @@ -160,6 +205,15 @@ unknown_rev: > >> barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)"); > >> } > >> > >> +static void rpi_model_init(void) > >> +{ > >> + rpi_set_usbethaddr(); > >> + if (models[rpi_board_rev].init) { > >> + models[rpi_board_rev].init(); > >> + rpi_add_led(); > >> + } > >> +} > >> + > >> static int rpi_mem_init(void) > >> { > >> u32 size = 0; > >> @@ -220,6 +274,7 @@ static int rpi_env_init(void) > >> > >> static int rpi_devices_init(void) > >> { > >> + rpi_model_init(); > >> bcm2835_register_mci(); > >> bcm2835_register_fb(); > >> armlinux_set_architecture(MACH_TYPE_BCM2708); > >> -- > >> 2.1.3 > >> > >> > >> _______________________________________________ > >> barebox mailing list > >> barebox@lists.infradead.org > >> http://lists.infradead.org/mailman/listinfo/barebox > > > > > > -- > > -- > > Best regards, > > Antony Pavlov > -- -- Best regards, Antony Pavlov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] raspberry-pi: add leds support 2015-01-13 10:11 ` Antony Pavlov @ 2015-01-14 6:26 ` Sascha Hauer 0 siblings, 0 replies; 19+ messages in thread From: Sascha Hauer @ 2015-01-14 6:26 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox On Tue, Jan 13, 2015 at 01:11:38PM +0300, Antony Pavlov wrote: > On Tue, 13 Jan 2015 16:15:45 +0800 > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > > > > > On Jan 13, 2015, at 3:58 PM, Antony Pavlov <antonynpavlov@gmail.com> wrote: > > > > > > On Tue, 13 Jan 2015 07:26:12 +0100 > > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote: > > > > > > I have planned to switch raspberry pi to device tree support as Linux does. > > > > but as I do not want to build multi binary switch (leds & co) those to DT make no sense except if we can > > chose the DT at runtime > > > > > > > > IMHO POWER LED is not GPIO controlable, please see these schematics > > > > yes it is does, I have a B+ and it’s controllable > > I'll check your series on my B+ in a few days. I merged this series for now, let me know when there are fixups necessary. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2015-01-19 12:16 UTC | newest] Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-01-13 6:31 [PATCH 0/6 v2] raspberry-pi: updates Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 2/6] raspberry-pi: add leds support Jean-Christophe PLAGNIOL-VILLARD 2015-01-18 22:08 ` Antony Pavlov 2015-01-19 7:51 ` Sascha Hauer 2015-01-19 7:58 ` Antony Pavlov 2015-01-19 7:59 ` Sascha Hauer 2015-01-19 12:16 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 3/6] amba: pl011: add support for regulator Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 4/6] driver: add postcore_platform_driver Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 5/6] regulator: allow to use it with non DT device Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:33 ` [PATCH 6/6] regulator: add bcm2835 driver Jean-Christophe PLAGNIOL-VILLARD 2015-01-14 6:24 ` [PATCH 0/6 v2] raspberry-pi: updates Sascha Hauer 2015-01-18 22:20 ` Antony Pavlov -- strict thread matches above, loose matches on Subject: below -- 2015-01-13 6:24 [PATCH 0/6] " Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:26 ` [PATCH 1/6] raspberry-pi: add board model detection Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 6:26 ` [PATCH 2/6] raspberry-pi: add leds support Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 7:58 ` Antony Pavlov 2015-01-13 8:15 ` Jean-Christophe PLAGNIOL-VILLARD 2015-01-13 10:11 ` Antony Pavlov 2015-01-14 6:26 ` Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox