Re: [PATCH 4/4] video: add support for Solomon SSD1307 OLED controller family
On Mon, Feb 27, 2017 at 04:45:43PM +0100, Bastian Stender wrote: > On 02/27/2017 11:08 AM, Sascha Hauer wrote: > > On Fri, Feb 24, 2017 at 03:25:01PM +0100, Bastian Stender wrote: > > > It was ported from linux v4.10. Like the kernel driver only > > > communication via I2C is supported. > > > > > > It has only been tested with a SSD1306 and a 96x16 OLED display: > > > > > >{ > > > status = "okay"; > > > > > > ssd1306: oled@3c { > > > compatible = "solomon,ssd1306fb-i2c"; > > > reg = <0x3c>; > > > reset-gpios = < 1 0>; > > > solomon,height = <16>; > > > solomon,width = <96>; > > > solomon,page-offset = <0>; > > > solomon,com-invdir; > > > solomon,com-seq; > > > }; > > > > > > Signed-off-by: Bastian Stender> > > --- > > > drivers/video/Kconfig | 4 + > > > drivers/video/Makefile| 1 + > > > drivers/video/ssd1307fb.c | 569 > > > ++ > > > 3 files changed, 574 insertions(+) > > > create mode 100644 drivers/video/ssd1307fb.c > > > > > > diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig > > > index 8f31f5af74..50a876acb1 100644 > > > --- a/drivers/video/Kconfig > > > +++ b/drivers/video/Kconfig > > > @@ -12,6 +12,10 @@ config FRAMEBUFFER_CONSOLE > > > select FONTS > > > prompt "framebuffer console support" > > > > > > +config DRIVER_VIDEO_FB_SSD1307 > > > + bool "Solomon SSD1307 framebuffer support" > > > + depends on PWM && I2C && GPIOLIB > > > + > > > config VIDEO_VPL > > > depends on OFTREE > > > bool > > > diff --git a/drivers/video/Makefile b/drivers/video/Makefile > > > index 1bf2e1f3ca..e23c9c37b6 100644 > > > --- a/drivers/video/Makefile > > > +++ b/drivers/video/Makefile > > > @@ -21,3 +21,4 @@ obj-$(CONFIG_DRIVER_VIDEO_OMAP) += omap.o > > > obj-$(CONFIG_DRIVER_VIDEO_BCM283X) += bcm2835.o > > > obj-$(CONFIG_DRIVER_VIDEO_SIMPLEFB) += simplefb.o > > > obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3) += imx-ipu-v3/ > > > +obj-$(CONFIG_DRIVER_VIDEO_FB_SSD1307) += ssd1307fb.o > > > diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c > > > new file mode 100644 > > > index 00..0dfdcc2232 > > > --- /dev/null > > > +++ b/drivers/video/ssd1307fb.c > > > @@ -0,0 +1,569 @@ > > > +/* > > > + * Driver for the Solomon SSD1307 OLED controller family > > > + * > > > + * Supports: > > > + * - SSD1305 (untested) > > > + * - SSD1306 > > > + * - SSD1307 (untested) > > > + * - SSD1309 (untested) > > > + * > > > + * Copyright 2012 Maxime Ripard , Free > > > Electrons > > > + * > > > + * Ported to barebox from linux v4.10 > > > + * Copyright (C) 2017 Pengutronix, Bastian Stender > > > > > > + * > > > + * Licensed under the GPLv2 or later. > > > + */ > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > + > > > +#define SSD1307FB_DATA 0x40 > > > +#define SSD1307FB_COMMAND0x80 > > > + > > > +#define SSD1307FB_SET_ADDRESS_MODE 0x20 > > > +#define SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL(0x00) > > > +#define SSD1307FB_SET_ADDRESS_MODE_VERTICAL (0x01) > > > +#define SSD1307FB_SET_ADDRESS_MODE_PAGE (0x02) > > > +#define SSD1307FB_SET_COL_RANGE 0x21 > > > +#define SSD1307FB_SET_PAGE_RANGE 0x22 > > > +#define SSD1307FB_CONTRAST 0x81 > > > +#define SSD1307FB_CHARGE_PUMP 0x8d > > > +#define SSD1307FB_SEG_REMAP_ON 0xa1 > > > +#define SSD1307FB_DISPLAY_OFF0xae > > > +#define SSD1307FB_SET_MULTIPLEX_RATIO0xa8 > > > +#define SSD1307FB_DISPLAY_ON 0xaf > > > +#define SSD1307FB_START_PAGE_ADDRESS 0xb0 > > > +#define SSD1307FB_SET_DISPLAY_OFFSET 0xd3 > > > +#define SSD1307FB_SET_CLOCK_FREQ0xd5 > > > +#define SSD1307FB_SET_PRECHARGE_PERIOD 0xd9 > > > +#define SSD1307FB_SET_COM_PINS_CONFIG 0xda > > > +#define SSD1307FB_SET_VCOMH 0xdb > > > > please consistently use spaces after #define > > Will do. > > > > > > + > > > +struct ssd1307fb_par; > > > > Unnecessary. > > Ok. > > > > > > + > > > +struct ssd1307fb_deviceinfo { > > > + u32 default_vcomh; > > > + u32 default_dclk_div; > > > + u32 default_dclk_frq; > > > + int need_chargepump; > > > +}; > > > + > > > > [...] > > > > > +static int ssd1307fb_probe(struct device_d *dev) > > > +{ > > > + struct i2c_client *client = to_i2c_client(dev); > > > + struct fb_info *info; > > > + struct device_node *node = dev->device_node; > > > + const struct of_device_id *match = > > > + of_match_node(ssd1307fb_of_match, dev->device_node); > > > + u32 vmem_size; > > > + struct ssd1307fb_par *par; > > > + struct ssd1307fb_array *array; > > > + u8 *vmem; > > > + int ret;
Re: [RFC] serial: ns16550: Set read/write functions depending on reg-io-width
On Mon, Feb 20, 2017 at 02:12:21PM +0100, Wadim Egorov wrote: > Is this patch okay? I hope so, it's already applied ;) Sascha > > > Am 09.02.2017 um 10:36 schrieb Wadim Egorov: > > Set proper register read/write functions depending on reg-io-width > > device tree property. > > > > Signed-off-by: Wadim Egorov> > --- > > > > of_platform_device_create() creates resources in the device_d struct. > > ns16550_init_iomem() and ns16550_init_ioport() are reading the resources > > and it's flags (register width). > > So both functions are not failing, because there is a valid resource. > > The res->flags might be not set at all. And if it is not set, the driver > > will use always IORESOURCE_MEM_8BIT. > > > > With this patch the probe_dt() func will override the read/write funcs, > > if there is a valid reg-io-width property. > > --- > > drivers/serial/serial_ns16550.c | 19 +++ > > 1 file changed, 19 insertions(+) > > > > diff --git a/drivers/serial/serial_ns16550.c > > b/drivers/serial/serial_ns16550.c > > index c6548e3..752e77b 100644 > > --- a/drivers/serial/serial_ns16550.c > > +++ b/drivers/serial/serial_ns16550.c > > @@ -287,12 +287,31 @@ static int ns16550_tstc(struct console_device *cdev) > > static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv > > *priv) > > { > > struct device_node *np = dev->device_node; > > + u32 width; > > > > if (!IS_ENABLED(CONFIG_OFDEVICE)) > > return; > > > > of_property_read_u32(np, "clock-frequency", >plat.clock); > > of_property_read_u32(np, "reg-shift", >plat.shift); > > + if (!of_property_read_u32(np, "reg-io-width", )) > > + switch (width) { > > + case 1: > > + priv->read_reg = ns16550_read_reg_mmio_8; > > + priv->write_reg = ns16550_write_reg_mmio_8; > > + break; > > + case 2: > > + priv->read_reg = ns16550_read_reg_mmio_16; > > + priv->write_reg = ns16550_write_reg_mmio_16; > > + break; > > + case 4: > > + priv->read_reg = ns16550_read_reg_mmio_32; > > + priv->write_reg = ns16550_write_reg_mmio_32; > > + break; > > + default: > > + dev_err(dev, "unsupported reg-io-width (%d)\n", > > + width); > > + } > > } > > > > static struct ns16550_drvdata ns16450_drvdata = { > > > ___ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox > -- 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2] console: expose consoles in devfs
On Mon, Feb 27, 2017 at 05:01:08PM +0100, Bastian Stender wrote: > This enables displaying text on e.g. a framebuffer console by issueing > > echo -o /dev/fbconsole0 abc123 > > Signed-off-by: Bastian Stender> --- > common/console.c | 52 > include/console.h | 3 +++ > 2 files changed, 55 insertions(+) > > diff --git a/common/console.c b/common/console.c > index 3ff32b8327..bde4c08414 100644 > --- a/common/console.c > +++ b/common/console.c > @@ -259,6 +259,39 @@ static int __console_puts(struct console_device *cdev, > const char *s) > return n; > } > > +static int fops_open(struct cdev *cdev, unsigned long flags) > +{ > + struct console_device *priv = cdev->priv; > + > + return console_open(priv); > +} > + > +static int fops_close(struct cdev *dev) > +{ > + struct console_device *priv = dev->priv; > + > + return console_close(priv); > +} > + > +static int fops_flush(struct cdev *dev) > +{ > + struct console_device *priv = dev->priv; > + > + priv->flush(priv); cdev->flush() is optional, you have to test for presence before using it. When you have to resend patches from a series, please resend the whole series. Scanning different mail threads to find the newest version of the patches can get cumbersome quite fast. 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2] console: replace set_active by open/close
On Mon, Feb 27, 2017 at 04:56:16PM +0100, Bastian Stender wrote: > Opening and closing consoles should be independent from setting them > active. This way it is possible to open e.g. a framebuffer console and > display text on it without showing stdout/stderr. > > Signed-off-by: Bastian Stender> --- > common/console.c | 31 +-- > drivers/video/fbconsole.c | 28 ++-- > include/console.h | 9 - > net/netconsole.c | 27 +-- > 4 files changed, 72 insertions(+), 23 deletions(-) > > diff --git a/common/console.c b/common/console.c > index 74ccfcfc3e..3ff32b8327 100644 > --- a/common/console.c > +++ b/common/console.c > @@ -59,6 +59,26 @@ static struct kfifo __console_output_fifo; > static struct kfifo *console_input_fifo = &__console_input_fifo; > static struct kfifo *console_output_fifo = &__console_output_fifo; > > +int console_open(struct console_device *cdev) > +{ > + if (cdev->open && !(cdev-> flags & FLAG_CONSOLE_OPEN)) { > + cdev->flags |= FLAG_CONSOLE_OPEN; > + return cdev->open(cdev); > + } What if cdev->open() fails? In this case the flag is still set, but the console is not opened. Also please set the FLAG_CONSOLE_OPEN independent of the presence of the cdev->open() hook. > diff --git a/include/console.h b/include/console.h > index 4b2f134a4c..85e15cad67 100644 > --- a/include/console.h > +++ b/include/console.h > @@ -28,6 +28,8 @@ > #define CONSOLE_STDOUT (1 << 1) > #define CONSOLE_STDERR (1 << 2) > > +#define FLAG_CONSOLE_OPEN (1 << 0) > + > enum console_mode { > CONSOLE_MODE_NORMAL, > CONSOLE_MODE_RS485, > @@ -44,7 +46,8 @@ struct console_device { > int (*setbrg)(struct console_device *cdev, int baudrate); > void (*flush)(struct console_device *cdev); > int (*set_mode)(struct console_device *cdev, enum console_mode mode); > - int (*set_active)(struct console_device *cdev, unsigned active); > + int (*open)(struct console_device *cdev); > + int (*close)(struct console_device *cdev); > > char *devname; > int devid; > @@ -54,6 +57,8 @@ struct console_device { > unsigned char f_active; > char active[4]; > > + unsigned flags; > + Flags often have the problem that you do not know which flag define belong to which flag field in which structure. One thing we can do is to add the flag #defines directly above the struct member they belong to in the source code. In this case here we should use a counter rather than flags. Consider two users opening the console at the same time. Now when one of the users closes the console, it must still remain opened for the other user. 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: Zyxel NAS540 bricked?
Hi Andrew, On Mon, Feb 27, 2017 at 05:03:57AM -0500, AndrewCz wrote: > Hello all, hope you are well. > > Recently, I followed a guide[1] to reflash my Zyxel NAS540[2] in order > to put Debian on it. I'm pretty sure I bricked it and am just looking > for confirmation. > > I seem to be running into a bootloop where it will restart every two > minutes or so. At least that is what seems to be indicated based on the > frequency of the front panel lights lighting up. I reflashed the 'env' > and 'kernel2' sections of the NOR flash, but neither went the right way. > I can dive into the specifics if necessary. However, my concern is that > I was unable to receive any output from the serial connection. > > Given that the barebox 'env' may be corrupt as well as the kernel, is it > correct to expect that there would be no serial output? Thanks for your > consideration in this matter. The Zyxel NAS540 seems to have a Freescale QorIQ LS1024A SoC. There is no mainline barebox support for this SoC, so Zyxel must have created their own patches. I know nothing about these patches nor about the SoC, so I'm sorry I can't really help you. What I can say is that normally barebox outputs stuff out of the console even without valid environment or kernel. That is configurable though, so I can't tell for sure. 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 5/8] clocksource: allow to have multiple device from clock source
On Mon, Feb 27, 2017 at 11:19:27AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote: > use the one with the most priority. > > We can not select the clocksource at user level. > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD> --- > common/clock.c | 11 +++ > include/clock.h | 3 ++- > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/common/clock.c b/common/clock.c > index 2c5dd91cc..d99d06853 100644 > --- a/common/clock.c > +++ b/common/clock.c > @@ -213,6 +213,17 @@ EXPORT_SYMBOL(mdelay_non_interruptible); > > int init_clock(struct clocksource *cs) > { > + if (current_clock && cs->priority < current_clock->priority) > + return -EBUSY; You should return successfully here. Otherwise driver probe functions return -EBUSY for something which is not the drivers fault. In fact, it's not an error, it's just that we currently don't have any use for an additional clock. Also consider testing for <= current_clock->priority instead of <. All current clocks have priority 0 and we want to initialize only the first one. 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 0/4] mvebu: Make 2nd-stage booting possible
On Sat, Feb 25, 2017 at 09:52:38PM +0100, Uwe Kleine-König wrote: > Hello, > > one specialty of mvebu is that it has a movable register window. Its > base address is configured within this register range, so there is no > way to find out the current position. The BootROM leaves this window at > 0xd000, however it is beneficial to move it further to the end of > the address range (usually 0xf100) to benefit from more continuous > RAM. For this reason one of the first things that barebox does it to > move the window accordingly. If however barebox is loaded as a second > stage image this results in a crash as the register base address > register is already moved. > > This series implements that the called image gets the base address from > the barebox header. It defaults to 0xd000 which is right for the > (unaware) BootROM and when barebox jumps into such an image the register > position is passed accordingly. This makes the 2nd stage images unnecessary, right? Can you remove them from images/Makefile.mvebu? 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2 3+0/3] retry on simplification of init code flow
On Sat, Feb 25, 2017 at 09:40:19PM +0100, Uwe Kleine-König wrote: > Hello, > > this series is v2 of [4-6]/3 from Feb 15 and is supposed to superseed > (implicit) v1 which is already in next. > > The difference is that patch "mvebu: Fix fixup of mbus device-tree > ranges" is squashed into them and the commit log adapted accordingly. Ok, applied. Please check if the result is correct in -next. Sascha > > Best regards > Uwe > > Uwe Kleine-König (3): > mvebu: armada-370-xp: simplify soc init code flow > mvebu: dove: simplify soc init code flow > mvebu: kirkwood: simplify soc init code flow > > arch/arm/mach-mvebu/armada-370-xp.c | 31 --- > arch/arm/mach-mvebu/dove.c | 13 ++--- > arch/arm/mach-mvebu/kirkwood.c | 11 ++- > drivers/bus/mvebu-mbus.c| 22 +- > 4 files changed, 33 insertions(+), 44 deletions(-) > > -- > 2.11.0 > > > ___ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox -- 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v3] fbconsole: check cursor position before moving
On Mon, Feb 27, 2017 at 02:39:30PM +0100, Bastian Stender wrote: > Moving the cursor to x=2, y=2 with "\e[3;3H" on a 12x2 framebuffer > console lead to a barebox crash while drawing the cursor. If the > cursor position is out of bounds clip the cursor to the corresponding > edge. > > Signed-off-by: Bastian StenderApplied, thanks Sascha > --- > drivers/video/fbconsole.c | 7 +-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c > index 64f7d7364e..33649c597d 100644 > --- a/drivers/video/fbconsole.c > +++ b/drivers/video/fbconsole.c > @@ -264,10 +264,13 @@ static void fbc_parse_csi(struct fbc_priv *priv) > return; > case 'H': > video_invertchar(priv, priv->x, priv->y); > + > pos = simple_strtoul(priv->csi, , 10); > - priv->y = pos ? pos - 1 : 0; > + priv->y = clamp(pos - 1, 0, (int) priv->rows); > + > pos = simple_strtoul(end + 1, NULL, 10); > - priv->x = pos ? pos - 1 : 0; > + priv->x = clamp(pos - 1, 0, (int) priv->cols); > + > video_invertchar(priv, priv->x, priv->y); > case 'K': > pos = simple_strtoul(priv->csi, , 10); > -- > 2.11.0 > > -- 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v3] fbconsole: check cursor position before moving
On 27/02/17 18:46, Ian Abbott wrote: On 27/02/17 13:39, Bastian Stender wrote: Moving the cursor to x=2, y=2 with "\e[3;3H" on a 12x2 framebuffer console lead to a barebox crash while drawing the cursor. If the cursor position is out of bounds clip the cursor to the corresponding edge. Signed-off-by: Bastian Stender--- drivers/video/fbconsole.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c index 64f7d7364e..33649c597d 100644 --- a/drivers/video/fbconsole.c +++ b/drivers/video/fbconsole.c @@ -264,10 +264,13 @@ static void fbc_parse_csi(struct fbc_priv *priv) return; case 'H': video_invertchar(priv, priv->x, priv->y); + pos = simple_strtoul(priv->csi, , 10); -priv->y = pos ? pos - 1 : 0; +priv->y = clamp(pos - 1, 0, (int) priv->rows); + That allows priv->y to be set to priv->rows, which is one too many. Ignore that. My mistake. It appears that priv->rows is the number of rows minus 1, so the above code is fine. Same for priv->x. -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v3] fbconsole: check cursor position before moving
On 27/02/17 13:39, Bastian Stender wrote: Moving the cursor to x=2, y=2 with "\e[3;3H" on a 12x2 framebuffer console lead to a barebox crash while drawing the cursor. If the cursor position is out of bounds clip the cursor to the corresponding edge. Signed-off-by: Bastian Stender--- drivers/video/fbconsole.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c index 64f7d7364e..33649c597d 100644 --- a/drivers/video/fbconsole.c +++ b/drivers/video/fbconsole.c @@ -264,10 +264,13 @@ static void fbc_parse_csi(struct fbc_priv *priv) return; case 'H': video_invertchar(priv, priv->x, priv->y); + pos = simple_strtoul(priv->csi, , 10); - priv->y = pos ? pos - 1 : 0; + priv->y = clamp(pos - 1, 0, (int) priv->rows); + That allows priv->y to be set to priv->rows, which is one too many. How about: priv->y = clamp(pos, 1, (int)priv->rows) - 1; ? pos = simple_strtoul(end + 1, NULL, 10); - priv->x = pos ? pos - 1 : 0; + priv->x = clamp(pos - 1, 0, (int) priv->cols); + Similar to above. video_invertchar(priv, priv->x, priv->y); case 'K': pos = simple_strtoul(priv->csi, , 10); -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH v2] console: expose consoles in devfs
This enables displaying text on e.g. a framebuffer console by issueing echo -o /dev/fbconsole0 abc123 Signed-off-by: Bastian Stender--- common/console.c | 52 include/console.h | 3 +++ 2 files changed, 55 insertions(+) diff --git a/common/console.c b/common/console.c index 3ff32b8327..bde4c08414 100644 --- a/common/console.c +++ b/common/console.c @@ -259,6 +259,39 @@ static int __console_puts(struct console_device *cdev, const char *s) return n; } +static int fops_open(struct cdev *cdev, unsigned long flags) +{ + struct console_device *priv = cdev->priv; + + return console_open(priv); +} + +static int fops_close(struct cdev *dev) +{ + struct console_device *priv = dev->priv; + + return console_close(priv); +} + +static int fops_flush(struct cdev *dev) +{ + struct console_device *priv = dev->priv; + + priv->flush(priv); + + return 0; +} + +static int fops_write(struct cdev* dev, const void* buf, size_t count, + loff_t offset, ulong flags) +{ + struct console_device *priv = dev->priv; + + priv->puts(priv, buf); + + return 0; +} + int console_register(struct console_device *newcdev) { struct device_d *dev = >class_dev; @@ -311,6 +344,25 @@ int console_register(struct console_device *newcdev) console_set_active(newcdev, CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR); + /* expose console as device in fs */ + newcdev->devfs.name = basprintf("%s%d", newcdev->class_dev.name, + newcdev->class_dev.id); + newcdev->devfs.priv = newcdev; + newcdev->devfs.dev = dev; + newcdev->devfs.ops = >fops; + newcdev->devfs.flags = DEVFS_IS_CHARACTER_DEV; + newcdev->fops.open = fops_open; + newcdev->fops.close = fops_close; + newcdev->fops.flush = fops_flush; + newcdev->fops.write = fops_write; + + ret = devfs_create(>devfs); + + if (ret) { + pr_err("device creation failed with %s\n", strerror(-ret)); + return ret; + } + return 0; } EXPORT_SYMBOL(console_register); diff --git a/include/console.h b/include/console.h index 85e15cad67..68edc3aaf1 100644 --- a/include/console.h +++ b/include/console.h @@ -63,6 +63,9 @@ struct console_device { unsigned int baudrate_param; const char *linux_console_name; + + struct cdev devfs; + struct file_operations fops; }; int console_register(struct console_device *cdev); -- 2.11.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH v2] console: replace set_active by open/close
Opening and closing consoles should be independent from setting them active. This way it is possible to open e.g. a framebuffer console and display text on it without showing stdout/stderr. Signed-off-by: Bastian Stender--- common/console.c | 31 +-- drivers/video/fbconsole.c | 28 ++-- include/console.h | 9 - net/netconsole.c | 27 +-- 4 files changed, 72 insertions(+), 23 deletions(-) diff --git a/common/console.c b/common/console.c index 74ccfcfc3e..3ff32b8327 100644 --- a/common/console.c +++ b/common/console.c @@ -59,6 +59,26 @@ static struct kfifo __console_output_fifo; static struct kfifo *console_input_fifo = &__console_input_fifo; static struct kfifo *console_output_fifo = &__console_output_fifo; +int console_open(struct console_device *cdev) +{ + if (cdev->open && !(cdev-> flags & FLAG_CONSOLE_OPEN)) { + cdev->flags |= FLAG_CONSOLE_OPEN; + return cdev->open(cdev); + } + + return 0; +} + +int console_close(struct console_device *cdev) +{ + if (cdev->close && cdev-> flags & FLAG_CONSOLE_OPEN) { + cdev->flags &= ~FLAG_CONSOLE_OPEN; + return cdev->close(cdev); + } + + return 0; +} + int console_set_active(struct console_device *cdev, unsigned flag) { int ret, i; @@ -71,8 +91,15 @@ int console_set_active(struct console_device *cdev, unsigned flag) if (!flag && cdev->f_active && cdev->flush) cdev->flush(cdev); - if (cdev->set_active) { - ret = cdev->set_active(cdev, flag); + if (flag == cdev->f_active) + return 0; + + if (!flag) { + ret = console_close(cdev); + if (ret) + return ret; + } else { + ret = console_open(cdev); if (ret) return ret; } diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c index 693c21f547..64f7d7364e 100644 --- a/drivers/video/fbconsole.c +++ b/drivers/video/fbconsole.c @@ -365,21 +365,13 @@ static int setup_font(struct fbc_priv *priv) return 0; } -static int fbc_set_active(struct console_device *cdev, unsigned flags) +static int fbc_open(struct console_device *cdev) { struct fbc_priv *priv = container_of(cdev, struct fbc_priv, cdev); struct fb_info *fb = priv->fb; int ret; - if (priv->active) { - fb_close(priv->sc); - priv->active = false; - } - - if (!(flags & (CONSOLE_STDOUT | CONSOLE_STDERR))) - return 0; - ret = setup_font(priv); if (ret) return ret; @@ -400,6 +392,21 @@ static int fbc_set_active(struct console_device *cdev, unsigned flags) return 0; } +static int fbc_close(struct console_device *cdev) +{ + struct fbc_priv *priv = container_of(cdev, + struct fbc_priv, cdev); + + if (priv->active) { + fb_close(priv->sc); + priv->active = false; + + return 0; + } + + return -EINVAL; +} + static int set_font(struct param_d *p, void *vpriv) { struct fbc_priv *priv = vpriv; @@ -434,7 +441,8 @@ int register_fbconsole(struct fb_info *fb) cdev->getc = fbc_getc; cdev->devname = "fbconsole"; cdev->devid = DEVICE_ID_DYNAMIC; - cdev->set_active = fbc_set_active; + cdev->open = fbc_open; + cdev->close = fbc_close; ret = console_register(cdev); if (ret) { diff --git a/include/console.h b/include/console.h index 4b2f134a4c..85e15cad67 100644 --- a/include/console.h +++ b/include/console.h @@ -28,6 +28,8 @@ #define CONSOLE_STDOUT (1 << 1) #define CONSOLE_STDERR (1 << 2) +#define FLAG_CONSOLE_OPEN (1 << 0) + enum console_mode { CONSOLE_MODE_NORMAL, CONSOLE_MODE_RS485, @@ -44,7 +46,8 @@ struct console_device { int (*setbrg)(struct console_device *cdev, int baudrate); void (*flush)(struct console_device *cdev); int (*set_mode)(struct console_device *cdev, enum console_mode mode); - int (*set_active)(struct console_device *cdev, unsigned active); + int (*open)(struct console_device *cdev); + int (*close)(struct console_device *cdev); char *devname; int devid; @@ -54,6 +57,8 @@ struct console_device { unsigned char f_active; char active[4]; + unsigned flags; + unsigned int baudrate; unsigned int baudrate_param; @@ -75,6 +80,8 @@ extern int barebox_loglevel; struct console_device *console_get_first_active(void); +int console_open(struct console_device *cdev); +int console_close(struct console_device *cdev); int console_set_active(struct console_device
Re: [PATCH 4/4] video: add support for Solomon SSD1307 OLED controller family
On 02/27/2017 11:08 AM, Sascha Hauer wrote: On Fri, Feb 24, 2017 at 03:25:01PM +0100, Bastian Stender wrote: It was ported from linux v4.10. Like the kernel driver only communication via I2C is supported. It has only been tested with a SSD1306 and a 96x16 OLED display: { status = "okay"; ssd1306: oled@3c { compatible = "solomon,ssd1306fb-i2c"; reg = <0x3c>; reset-gpios = < 1 0>; solomon,height = <16>; solomon,width = <96>; solomon,page-offset = <0>; solomon,com-invdir; solomon,com-seq; }; Signed-off-by: Bastian Stender--- drivers/video/Kconfig | 4 + drivers/video/Makefile| 1 + drivers/video/ssd1307fb.c | 569 ++ 3 files changed, 574 insertions(+) create mode 100644 drivers/video/ssd1307fb.c diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 8f31f5af74..50a876acb1 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -12,6 +12,10 @@ config FRAMEBUFFER_CONSOLE select FONTS prompt "framebuffer console support" +config DRIVER_VIDEO_FB_SSD1307 + bool "Solomon SSD1307 framebuffer support" + depends on PWM && I2C && GPIOLIB + config VIDEO_VPL depends on OFTREE bool diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 1bf2e1f3ca..e23c9c37b6 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -21,3 +21,4 @@ obj-$(CONFIG_DRIVER_VIDEO_OMAP) += omap.o obj-$(CONFIG_DRIVER_VIDEO_BCM283X) += bcm2835.o obj-$(CONFIG_DRIVER_VIDEO_SIMPLEFB) += simplefb.o obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3) += imx-ipu-v3/ +obj-$(CONFIG_DRIVER_VIDEO_FB_SSD1307) += ssd1307fb.o diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c new file mode 100644 index 00..0dfdcc2232 --- /dev/null +++ b/drivers/video/ssd1307fb.c @@ -0,0 +1,569 @@ +/* + * Driver for the Solomon SSD1307 OLED controller family + * + * Supports: + * - SSD1305 (untested) + * - SSD1306 + * - SSD1307 (untested) + * - SSD1309 (untested) + * + * Copyright 2012 Maxime Ripard , Free Electrons + * + * Ported to barebox from linux v4.10 + * Copyright (C) 2017 Pengutronix, Bastian Stender + * + * Licensed under the GPLv2 or later. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SSD1307FB_DATA 0x40 +#define SSD1307FB_COMMAND 0x80 + +#define SSD1307FB_SET_ADDRESS_MODE 0x20 +#define SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL (0x00) +#define SSD1307FB_SET_ADDRESS_MODE_VERTICAL(0x01) +#define SSD1307FB_SET_ADDRESS_MODE_PAGE(0x02) +#define SSD1307FB_SET_COL_RANGE0x21 +#define SSD1307FB_SET_PAGE_RANGE 0x22 +#define SSD1307FB_CONTRAST 0x81 +#defineSSD1307FB_CHARGE_PUMP 0x8d +#define SSD1307FB_SEG_REMAP_ON 0xa1 +#define SSD1307FB_DISPLAY_OFF 0xae +#define SSD1307FB_SET_MULTIPLEX_RATIO 0xa8 +#define SSD1307FB_DISPLAY_ON 0xaf +#define SSD1307FB_START_PAGE_ADDRESS 0xb0 +#define SSD1307FB_SET_DISPLAY_OFFSET 0xd3 +#defineSSD1307FB_SET_CLOCK_FREQ0xd5 +#defineSSD1307FB_SET_PRECHARGE_PERIOD 0xd9 +#defineSSD1307FB_SET_COM_PINS_CONFIG 0xda +#defineSSD1307FB_SET_VCOMH 0xdb please consistently use spaces after #define Will do. + +struct ssd1307fb_par; Unnecessary. Ok. + +struct ssd1307fb_deviceinfo { + u32 default_vcomh; + u32 default_dclk_div; + u32 default_dclk_frq; + int need_chargepump; +}; + [...] +static int ssd1307fb_probe(struct device_d *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct fb_info *info; + struct device_node *node = dev->device_node; + const struct of_device_id *match = + of_match_node(ssd1307fb_of_match, dev->device_node); + u32 vmem_size; + struct ssd1307fb_par *par; + struct ssd1307fb_array *array; + u8 *vmem; + int ret; + int i, j; + + if (!node) { + dev_err(>dev, "No device tree data found!\n"); + return -EINVAL; + } + + info = xzalloc(sizeof(struct fb_info)); + if (!info) { + dev_err(>dev, "Couldn't allocate framebuffer.\n"); + return -ENOMEM; + } xzalloc always returns succesfully, no need to check. Ok. + + par = info->priv; + par->info = info; + par->client = client; + + par->device_info = (struct ssd1307fb_deviceinfo *)match->data; + + par->reset = of_get_named_gpio(node, +"reset-gpios", 0); + if
[PATCH v3] fbconsole: check cursor position before moving
Moving the cursor to x=2, y=2 with "\e[3;3H" on a 12x2 framebuffer console lead to a barebox crash while drawing the cursor. If the cursor position is out of bounds clip the cursor to the corresponding edge. Signed-off-by: Bastian Stender--- drivers/video/fbconsole.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c index 64f7d7364e..33649c597d 100644 --- a/drivers/video/fbconsole.c +++ b/drivers/video/fbconsole.c @@ -264,10 +264,13 @@ static void fbc_parse_csi(struct fbc_priv *priv) return; case 'H': video_invertchar(priv, priv->x, priv->y); + pos = simple_strtoul(priv->csi, , 10); - priv->y = pos ? pos - 1 : 0; + priv->y = clamp(pos - 1, 0, (int) priv->rows); + pos = simple_strtoul(end + 1, NULL, 10); - priv->x = pos ? pos - 1 : 0; + priv->x = clamp(pos - 1, 0, (int) priv->cols); + video_invertchar(priv, priv->x, priv->y); case 'K': pos = simple_strtoul(priv->csi, , 10); -- 2.11.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 5/8] clocksource: allow to have multiple device from clock source
use the one with the most priority. We can not select the clocksource at user level. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD--- common/clock.c | 11 +++ include/clock.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/clock.c b/common/clock.c index 2c5dd91cc..d99d06853 100644 --- a/common/clock.c +++ b/common/clock.c @@ -213,6 +213,17 @@ EXPORT_SYMBOL(mdelay_non_interruptible); int init_clock(struct clocksource *cs) { + if (current_clock && cs->priority < current_clock->priority) + return -EBUSY; + + if (cs->init) { + int ret; + + ret = cs->init(cs); + if (ret) + return ret; + } + current_clock = cs; time_beginning = get_time_ns(); diff --git a/include/clock.h b/include/clock.h index d65e404e8..5f2f53ab6 100644 --- a/include/clock.h +++ b/include/clock.h @@ -12,7 +12,8 @@ struct clocksource { uint64_t(*read)(void); uint64_tcycle_last; uint64_tmask; - + int priority; + int (*init)(struct clocksource*); }; static inline uint32_t cyc2ns(struct clocksource *cs, uint64_t cycles) -- 2.11.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 8/8] efi: add veriable to report secure boot support and status
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD--- drivers/efi/efi-device.c | 33 + 1 file changed, 33 insertions(+) diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c index db8b25147..6ed7f12b3 100644 --- a/drivers/efi/efi-device.c +++ b/drivers/efi/efi-device.c @@ -354,11 +354,41 @@ static void efi_businfo(struct device_d *dev) } } +static int efi_is_secure_boot(void) +{ + uint8_t *val; + int ret = 0; + + val = efi_get_variable("SecureBoot", _global_variable_guid, NULL); + if (!IS_ERR(val)) { + ret = *val; + free(val); + } + + return ret != 1; +} + +static int efi_is_setup_mode(void) +{ + uint8_t *val; + int ret = 0; + + val = efi_get_variable("SetupMode", _global_variable_guid, NULL); + if (!IS_ERR(val)) { + ret = *val; + free(val); + } + + return ret != 1; +} + static int efi_init_devices(void) { char *fw_vendor = NULL; u16 sys_major = efi_sys_table->hdr.revision >> 16; u16 sys_minor = efi_sys_table->hdr.revision & 0x; + int secure_boot = efi_is_secure_boot(); + int setup_mode = efi_is_setup_mode(); fw_vendor = strdup_wchar_to_char((const wchar_t *)efi_sys_table->fw_vendor); @@ -374,6 +404,9 @@ static int efi_init_devices(void) dev_add_param_int_ro(efi_bus.dev, "major", sys_major, "%u"); dev_add_param_int_ro(efi_bus.dev, "minor", sys_minor, "%u"); dev_add_param_int_ro(efi_bus.dev, "fw_revision", efi_sys_table->fw_revision, "%u"); + dev_add_param_int_ro(efi_bus.dev, "secure_boot", secure_boot, "%d"); + dev_add_param_int_ro(efi_bus.dev, "secure_mode", +secure_boot & setup_mode, "%u"); efi_bus.dev->info = efi_businfo; -- 2.11.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 7/8] efi: clocksoure: use event for timer
with this we can be hw generic If the EFI implement timestamp protocol we could use instead of event but even EDK2 Never Ever compile it for any target. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD--- common/efi/efi.c | 8 drivers/clocksource/Kconfig | 4 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/efi.c| 110 +++ 4 files changed, 123 insertions(+) create mode 100644 drivers/clocksource/efi.c diff --git a/common/efi/efi.c b/common/efi/efi.c index 4b589b600..05c58250f 100644 --- a/common/efi/efi.c +++ b/common/efi/efi.c @@ -353,6 +353,14 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table) return EFI_SUCCESS; } +static int efi_core_init(void) +{ + struct device_d *dev = device_alloc("efi-cs", DEVICE_ID_SINGLE); + + return platform_device_register(dev); +} +core_initcall(efi_core_init); + static int efi_postcore_init(void) { char *uuid; diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 9b7f0a9d7..b12a85403 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -34,6 +34,10 @@ config CLOCKSOURCE_DUMMY_RATE The option CONFIG_CLOCKSOURCE_DUMMY_RATE is used to adjust this clocksource. The bigger rate valuest makes clocksource "faster". +config CLOCKSOURCE_EFI + bool "Generic EFI Driver" + depends on EFI_BOOTUP + config CLOCKSOURCE_EFI_X86 bool "EFI X86 HW driver" depends on EFI_BOOTUP && X86 diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 1fd18296e..f69b33d0b 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_ARM_SMP_TWD) += arm_smp_twd.o obj-$(CONFIG_CLOCKSOURCE_BCM283X) += bcm2835.o obj-$(CONFIG_CLOCKSOURCE_CLPS711X) += clps711x.o obj-$(CONFIG_CLOCKSOURCE_DIGIC) += digic.o +obj-$(CONFIG_CLOCKSOURCE_EFI) += efi.o obj-$(CONFIG_CLOCKSOURCE_EFI_X86) += efi_x86.o obj-$(CONFIG_CLOCKSOURCE_MVEBU) += mvebu.o obj-$(CONFIG_CLOCKSOURCE_NOMADIK) += nomadik.o diff --git a/drivers/clocksource/efi.c b/drivers/clocksource/efi.c new file mode 100644 index 0..df65dd86c --- /dev/null +++ b/drivers/clocksource/efi.c @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD + * + * Under GPL v2 + */ +#include +#include +#include +#include +#include +#include +#include +#include + +static uint64_t ticks = 1; +static void *efi_cs_evt; + +static uint64_t efi_cs_read(void) +{ + return ticks; +} + +static void efi_cs_inc(void *event, void *ctx) +{ + ticks++; +} + +/* count ticks during a 1dms */ +static uint64_t ticks_freq(void) +{ + uint64_t ticks_start, ticks_end; + + ticks_start = ticks; + BS->stall(1000); + ticks_end = ticks; + + return (ticks_end - ticks_start) * 1000; +} + +/* count ticks during a 20ms delay as on qemu x86_64 the max is 100Hz */ +static uint64_t ticks_freq_x86(void) +{ + uint64_t ticks_start, ticks_end; + + ticks_start = ticks; + BS->stall(20 * 1000); + ticks_end = ticks; + + return (ticks_end - ticks_start) * 50; +} + +static int efi_cs_init(struct clocksource *cs) +{ + efi_status_t efiret; + uint64_t freq; + + efiret = BS->create_event(EFI_EVT_TIMER | EFI_EVT_NOTIFY_SIGNAL, + EFI_TPL_CALLBACK, efi_cs_inc, NULL, _cs_evt); + + if (EFI_ERROR(efiret)) + return -efi_errno(efiret); + + efiret = BS->set_timer(efi_cs_evt, EFI_TIMER_PERIODIC, 10); + if (EFI_ERROR(efiret)) { + BS->close_event(efi_cs_evt); + return -efi_errno(efiret); + } + + freq = 1000 * 1000; + if (ticks_freq() < 800 * 1000) { + uint64_t nb_100ns; + + freq = ticks_freq_x86(); + nb_100ns = 10 * 1000 * 1000 / freq; + pr_warn("EFI Event timer too slow freq = %llu Hz\n", freq); + efiret = BS->set_timer(efi_cs_evt, EFI_TIMER_PERIODIC, nb_100ns); + if (EFI_ERROR(efiret)) { + BS->close_event(efi_cs_evt); + return -efi_errno(efiret); + } + } + + cs->mult = clocksource_hz2mult(freq, cs->shift); + + return 0; +} + +static struct clocksource efi_cs = { + .read = efi_cs_read, + .mask = CLOCKSOURCE_MASK(64), + .shift = 0, + .init = efi_cs_init, +}; + +static int efi_cs_probe(struct device_d *dev) +{ + return init_clock(_cs); +} + +static struct driver_d efi_cs_driver = { + .name = "efi-cs", + .probe = efi_cs_probe, +}; + +static int efi_cs_initcall(void) +{ + return platform_driver_register(_cs_driver); +} +/* for efi the time must be init at core initcall level */ +late_initcall(efi_cs_initcall); -- 2.11.0
[PATCH 6/8] efi: move x86 clocksource to device/driver
so we can dynamicly register the device As we may need to use HW IP for clocksource. As on EFI we could use Timestamp GUID if present (Not often the case as it's not even enabled by default on any Target on EDK II not even OVMF) Or if we choose we could use a Simulated Timestamp driver that work on Event (Add Later) Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD--- arch/x86/Kconfig | 2 +- arch/x86/mach-efi/Makefile | 1 + arch/x86/mach-efi/clocksource.c | 11 +++ drivers/clocksource/Kconfig | 6 +++--- drivers/clocksource/Makefile | 2 +- drivers/clocksource/{efi.c => efi_x86.c} | 34 6 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 arch/x86/mach-efi/clocksource.c rename drivers/clocksource/{efi.c => efi_x86.c} (56%) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 9803f3f95..52ccf4894 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -77,7 +77,7 @@ choice select EFI_GUID select EFI_DEVICEPATH select PRINTF_UUID - select CLOCKSOURCE_EFI + select CLOCKSOURCE_EFI_X86 config X86_BIOS_BRINGUP bool "16 bit BIOS" diff --git a/arch/x86/mach-efi/Makefile b/arch/x86/mach-efi/Makefile index c8a97bae0..f633e7c7e 100644 --- a/arch/x86/mach-efi/Makefile +++ b/arch/x86/mach-efi/Makefile @@ -1,4 +1,5 @@ obj-$(CONFIG_X86_64) += reloc_x86_64.o crt0-efi-x86_64.o obj-$(CONFIG_X86_32) += reloc_ia32.o crt0-efi-ia32.o +obj-y += clocksource.o extra-$(CONFIG_X86_32) += elf_ia32_efi.lds extra-$(CONFIG_X86_64) += elf_x86_64_efi.lds diff --git a/arch/x86/mach-efi/clocksource.c b/arch/x86/mach-efi/clocksource.c new file mode 100644 index 0..2023fa19a --- /dev/null +++ b/arch/x86/mach-efi/clocksource.c @@ -0,0 +1,11 @@ +#include +#include +#include + +static int efi_x86_pure_init(void) +{ + struct device_d *dev = device_alloc("efi-cs-x86", DEVICE_ID_SINGLE); + + return platform_device_register(dev); +} +core_initcall(efi_x86_pure_init); diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 54b05bbf3..9b7f0a9d7 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -34,9 +34,9 @@ config CLOCKSOURCE_DUMMY_RATE The option CONFIG_CLOCKSOURCE_DUMMY_RATE is used to adjust this clocksource. The bigger rate valuest makes clocksource "faster". -config CLOCKSOURCE_EFI - bool - depends on EFI_BOOTUP +config CLOCKSOURCE_EFI_X86 + bool "EFI X86 HW driver" + depends on EFI_BOOTUP && X86 config CLOCKSOURCE_MVEBU bool diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index e83fdeeec..1fd18296e 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -3,7 +3,7 @@ obj-$(CONFIG_ARM_SMP_TWD) += arm_smp_twd.o obj-$(CONFIG_CLOCKSOURCE_BCM283X) += bcm2835.o obj-$(CONFIG_CLOCKSOURCE_CLPS711X) += clps711x.o obj-$(CONFIG_CLOCKSOURCE_DIGIC) += digic.o -obj-$(CONFIG_CLOCKSOURCE_EFI) += efi.o +obj-$(CONFIG_CLOCKSOURCE_EFI_X86) += efi_x86.o obj-$(CONFIG_CLOCKSOURCE_MVEBU) += mvebu.o obj-$(CONFIG_CLOCKSOURCE_NOMADIK) += nomadik.o obj-$(CONFIG_CLOCKSOURCE_ORION) += orion.o diff --git a/drivers/clocksource/efi.c b/drivers/clocksource/efi_x86.c similarity index 56% rename from drivers/clocksource/efi.c rename to drivers/clocksource/efi_x86.c index 6d2fee8eb..4d2657ea1 100644 --- a/drivers/clocksource/efi.c +++ b/drivers/clocksource/efi_x86.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -38,24 +39,41 @@ static uint64_t ticks_freq(void) return (ticks_end - ticks_start) * 1000; } -static uint64_t efi_clocksource_read(void) +static uint64_t efi_x86_cs_read(void) { return 1000 * 1000 * ticks_read() / freq; } -static struct clocksource cs = { - .read = efi_clocksource_read, +static int efi_x86_cs_init(struct clocksource *cs) +{ + cs->mult = clocksource_hz2mult(1000 * 1000, cs->shift); + + freq = ticks_freq(); + + return 0; +} + +static struct clocksource efi_x86_cs = { + .read = efi_x86_cs_read, .mask = CLOCKSOURCE_MASK(64), .shift = 0, + .priority = 100, + .init = efi_x86_cs_init, }; -static int efi_clocksource_init(void) +static int efi_x86_cs_probe(struct device_d *dev) { - cs.mult = clocksource_hz2mult(1000 * 1000, cs.shift); + return init_clock(_x86_cs); +} - freq = ticks_freq(); +static struct driver_d efi_x86_cs_driver = { + .name = "efi-cs-x86", + .probe = efi_x86_cs_probe, +}; - return init_clock(); +static int efi_x86_cs_initcall(void) +{ + return platform_driver_register(_x86_cs_driver); } /* for efi the time must be init at core initcall level */ -core_initcall(efi_clocksource_init);
[PATCH 3/8] efi: move LoaderTimeInitUSec and LoaderDevicePartUUID to postcore initcall
so we can use device/driver for the timer Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD--- common/efi/efi.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common/efi/efi.c b/common/efi/efi.c index 217a6bea8..1c7aee872 100644 --- a/common/efi/efi.c +++ b/common/efi/efi.c @@ -314,7 +314,6 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table) efi_physical_addr_t mem; size_t memsize; efi_status_t efiret; - char *uuid; #ifdef DEBUG sys_table->con_out->output_string(sys_table->con_out, L"barebox\n"); @@ -350,6 +349,15 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table) mem_malloc_init((void *)mem, (void *)mem + memsize); efi_clocksource_init(); + start_barebox(); + + return EFI_SUCCESS; +} + +static int efi_postcore_init(void) +{ + char *uuid; + efi_set_variable_usec("LoaderTimeInitUSec", _systemd_vendor_guid, get_time_ns()/1000); @@ -366,10 +374,9 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table) free(uuid16); } - start_barebox(); - - return EFI_SUCCESS; + return 0; } +postcore_initcall(efi_postcore_init); static int do_efiexit(int argc, char *argv[]) { -- 2.11.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 2/8] efi: add prototype and definition for setting timer
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD--- include/efi.h | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/efi.h b/include/efi.h index f65980687..e1fc134ee 100644 --- a/include/efi.h +++ b/include/efi.h @@ -171,6 +171,12 @@ struct efi_open_protocol_information_entry { u32 open_count; }; +typedef enum { + EFI_TIMER_CANCEL = 0, + EFI_TIMER_PERIODIC = 1, + EFI_TIMER_RELATIVE = 2 +} efi_timer_delay_t; + /* * EFI Boot Services table */ @@ -199,7 +205,7 @@ typedef struct { efi_status_t(EFIAPI *create_event)(u32 type , unsigned long tpl, void (*fn) (void *event, void *ctx), void *ctx, void **event); - void *set_timer; + efi_status_t(EFIAPI *set_timer)(void *event, efi_timer_delay_t type, uint64_t time); efi_status_t(EFIAPI *wait_for_event)(unsigned long number_of_events, void *event, unsigned long *index); void *signal_event; -- 2.11.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 4/8] efi: move x86 clocksource init at core initcall level
so we can use device/driver model Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD--- common/efi/efi.c | 1 - drivers/clocksource/efi.c | 5 - include/efi/efi.h | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/efi/efi.c b/common/efi/efi.c index 1c7aee872..4b589b600 100644 --- a/common/efi/efi.c +++ b/common/efi/efi.c @@ -348,7 +348,6 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table) efi_strerror(efiret)); mem_malloc_init((void *)mem, (void *)mem + memsize); - efi_clocksource_init(); start_barebox(); return EFI_SUCCESS; diff --git a/drivers/clocksource/efi.c b/drivers/clocksource/efi.c index 59fd9918a..6d2fee8eb 100644 --- a/drivers/clocksource/efi.c +++ b/drivers/clocksource/efi.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -48,7 +49,7 @@ static struct clocksource cs = { .shift = 0, }; -int efi_clocksource_init(void) +static int efi_clocksource_init(void) { cs.mult = clocksource_hz2mult(1000 * 1000, cs.shift); @@ -56,3 +57,5 @@ int efi_clocksource_init(void) return init_clock(); } +/* for efi the time must be init at core initcall level */ +core_initcall(efi_clocksource_init); diff --git a/include/efi/efi.h b/include/efi/efi.h index 2b25cf186..648afb9ec 100644 --- a/include/efi/efi.h +++ b/include/efi/efi.h @@ -12,8 +12,6 @@ extern efi_loaded_image_t *efi_loaded_image; int efi_errno(efi_status_t err); -int efi_clocksource_init(void); - void *efi_get_variable(char *name, efi_guid_t *vendor, int *var_size); static inline void *efi_get_global_var(char *name, int *var_size) -- 2.11.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 1/8] efi: add prototype and definition for creating and closing event
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD--- include/efi.h | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/include/efi.h b/include/efi.h index 5691f4e8f..f65980687 100644 --- a/include/efi.h +++ b/include/efi.h @@ -185,12 +185,25 @@ typedef struct { unsigned long *, u32 *); efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **); efi_status_t (EFIAPI *free_pool)(void *); - void *create_event; +#define EFI_EVT_TIMER 0x8000 +#define EFI_EVT_RUNTIME0x4000 +#define EFI_EVT_NOTIFY_WAIT0x0100 +#define EFI_EVT_NOTIFY_SIGNAL 0x0200 +#define EFI_EVT_SIGNAL_EXIT_BOOT_SERVICES 0x0201 +#define EFI_EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x6202 + +#define EFI_TPL_APPLICATION4 +#define EFI_TPL_CALLBACK 8 +#define EFI_TPL_NOTIFY 16 +#define EFI_TPL_HIGH_LEVEL 31 + efi_status_t(EFIAPI *create_event)(u32 type , unsigned long tpl, + void (*fn) (void *event, void *ctx), + void *ctx, void **event); void *set_timer; efi_status_t(EFIAPI *wait_for_event)(unsigned long number_of_events, void *event, unsigned long *index); void *signal_event; - void *close_event; + efi_status_t(EFIAPI *close_event)(void *event); void *check_event; void *install_protocol_interface; void *reinstall_protocol_interface; -- 2.11.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 4/4] video: add support for Solomon SSD1307 OLED controller family
On Fri, Feb 24, 2017 at 03:25:01PM +0100, Bastian Stender wrote: > It was ported from linux v4.10. Like the kernel driver only > communication via I2C is supported. > > It has only been tested with a SSD1306 and a 96x16 OLED display: > >{ > status = "okay"; > > ssd1306: oled@3c { > compatible = "solomon,ssd1306fb-i2c"; > reg = <0x3c>; > reset-gpios = < 1 0>; > solomon,height = <16>; > solomon,width = <96>; > solomon,page-offset = <0>; > solomon,com-invdir; > solomon,com-seq; > }; > > Signed-off-by: Bastian Stender> --- > drivers/video/Kconfig | 4 + > drivers/video/Makefile| 1 + > drivers/video/ssd1307fb.c | 569 > ++ > 3 files changed, 574 insertions(+) > create mode 100644 drivers/video/ssd1307fb.c > > diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig > index 8f31f5af74..50a876acb1 100644 > --- a/drivers/video/Kconfig > +++ b/drivers/video/Kconfig > @@ -12,6 +12,10 @@ config FRAMEBUFFER_CONSOLE > select FONTS > prompt "framebuffer console support" > > +config DRIVER_VIDEO_FB_SSD1307 > + bool "Solomon SSD1307 framebuffer support" > + depends on PWM && I2C && GPIOLIB > + > config VIDEO_VPL > depends on OFTREE > bool > diff --git a/drivers/video/Makefile b/drivers/video/Makefile > index 1bf2e1f3ca..e23c9c37b6 100644 > --- a/drivers/video/Makefile > +++ b/drivers/video/Makefile > @@ -21,3 +21,4 @@ obj-$(CONFIG_DRIVER_VIDEO_OMAP) += omap.o > obj-$(CONFIG_DRIVER_VIDEO_BCM283X) += bcm2835.o > obj-$(CONFIG_DRIVER_VIDEO_SIMPLEFB) += simplefb.o > obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3) += imx-ipu-v3/ > +obj-$(CONFIG_DRIVER_VIDEO_FB_SSD1307) += ssd1307fb.o > diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c > new file mode 100644 > index 00..0dfdcc2232 > --- /dev/null > +++ b/drivers/video/ssd1307fb.c > @@ -0,0 +1,569 @@ > +/* > + * Driver for the Solomon SSD1307 OLED controller family > + * > + * Supports: > + * - SSD1305 (untested) > + * - SSD1306 > + * - SSD1307 (untested) > + * - SSD1309 (untested) > + * > + * Copyright 2012 Maxime Ripard , Free > Electrons > + * > + * Ported to barebox from linux v4.10 > + * Copyright (C) 2017 Pengutronix, Bastian Stender > + * > + * Licensed under the GPLv2 or later. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define SSD1307FB_DATA 0x40 > +#define SSD1307FB_COMMAND0x80 > + > +#define SSD1307FB_SET_ADDRESS_MODE 0x20 > +#define SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL(0x00) > +#define SSD1307FB_SET_ADDRESS_MODE_VERTICAL (0x01) > +#define SSD1307FB_SET_ADDRESS_MODE_PAGE (0x02) > +#define SSD1307FB_SET_COL_RANGE 0x21 > +#define SSD1307FB_SET_PAGE_RANGE 0x22 > +#define SSD1307FB_CONTRAST 0x81 > +#define SSD1307FB_CHARGE_PUMP 0x8d > +#define SSD1307FB_SEG_REMAP_ON 0xa1 > +#define SSD1307FB_DISPLAY_OFF0xae > +#define SSD1307FB_SET_MULTIPLEX_RATIO0xa8 > +#define SSD1307FB_DISPLAY_ON 0xaf > +#define SSD1307FB_START_PAGE_ADDRESS 0xb0 > +#define SSD1307FB_SET_DISPLAY_OFFSET 0xd3 > +#define SSD1307FB_SET_CLOCK_FREQ0xd5 > +#define SSD1307FB_SET_PRECHARGE_PERIOD 0xd9 > +#define SSD1307FB_SET_COM_PINS_CONFIG 0xda > +#define SSD1307FB_SET_VCOMH 0xdb please consistently use spaces after #define > + > +struct ssd1307fb_par; Unnecessary. > + > +struct ssd1307fb_deviceinfo { > + u32 default_vcomh; > + u32 default_dclk_div; > + u32 default_dclk_frq; > + int need_chargepump; > +}; > + [...] > +static int ssd1307fb_probe(struct device_d *dev) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + struct fb_info *info; > + struct device_node *node = dev->device_node; > + const struct of_device_id *match = > + of_match_node(ssd1307fb_of_match, dev->device_node); > + u32 vmem_size; > + struct ssd1307fb_par *par; > + struct ssd1307fb_array *array; > + u8 *vmem; > + int ret; > + int i, j; > + > + if (!node) { > + dev_err(>dev, "No device tree data found!\n"); > + return -EINVAL; > + } > + > + info = xzalloc(sizeof(struct fb_info)); > + if (!info) { > + dev_err(>dev, "Couldn't allocate framebuffer.\n"); > + return -ENOMEM; > + } xzalloc always returns succesfully, no need to check. > + > + par = info->priv; > + par->info = info; > + par->client = client; > + > + par->device_info = (struct ssd1307fb_deviceinfo *)match->data; > + > +
[PATCH 0/8] add generic EFI timer
Hi, On EFI you have 3 ways to get to do "timer" 1: Simply by waiting X us and calling Boot Service udelay 2: By using event 3: By use the Timestamp GUID for barebox this would be the best but even on EDK II this is never ever compiled on any target. So we have 2 choice, use a Hardware specific timer or implement the timer using timestamp This pull request allow you to enable 2 timers and use the best one at runtime. EFI x86 (HW specific) EFI Generic (based on Event) please pull The following changes since commit d92ed454107b4d6f0d30fa0271da191ae5911d18: Merge branch 'for-next/video' into next (2017-02-27 08:51:08 +0100) are available in the git repository at: git://git.jcrosoft.org/barebox.git for you to fetch changes up to 169af081c48d6739a3727f07a4b8dbfb7ab48ebb: efi: add veriable to report secure boot support and status (2017-02-27 18:20:37 +0800) Jean-Christophe PLAGNIOL-VILLARD (8): efi: add prototype and definition for creating and closing event efi: add prototype and definition for setting timer efi: move LoaderTimeInitUSec and LoaderDevicePartUUID to postcore initcall efi: move x86 clocksource init at core initcall level clocksource: allow to have multiple device from clock source efi: move x86 clocksource to device/driver efi: clocksoure: use event for timer efi: add veriable to report secure boot support and status arch/x86/Kconfig| 2 +- arch/x86/mach-efi/Makefile | 1 + arch/x86/mach-efi/clocksource.c | 11 +++ common/clock.c | 11 +++ common/efi/efi.c| 24 +++- drivers/clocksource/Kconfig | 6 +- drivers/clocksource/Makefile| 1 + drivers/clocksource/efi.c | 110 +- drivers/clocksource/efi_x86.c | 79 +++ drivers/efi/efi-device.c| 33 + include/clock.h | 3 ++- include/efi.h | 25 ++--- include/efi/efi.h | 2 -- 13 files changed, 266 insertions(+), 42 deletions(-) create mode 100644 arch/x86/mach-efi/clocksource.c create mode 100644 drivers/clocksource/efi_x86.c Best Regards, J. ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Zyxel NAS540 bricked?
Hello all, hope you are well. Recently, I followed a guide[1] to reflash my Zyxel NAS540[2] in order to put Debian on it. I'm pretty sure I bricked it and am just looking for confirmation. I seem to be running into a bootloop where it will restart every two minutes or so. At least that is what seems to be indicated based on the frequency of the front panel lights lighting up. I reflashed the 'env' and 'kernel2' sections of the NOR flash, but neither went the right way. I can dive into the specifics if necessary. However, my concern is that I was unable to receive any output from the serial connection. Given that the barebox 'env' may be corrupt as well as the kernel, is it correct to expect that there would be no serial output? Thanks for your consideration in this matter. --Andrew Cz [1] https://l.unchti.me/2016/02/12/debian-nas540.html [2] http://zyxel.nas-central.org/wiki/Category:NAS540 -- Only an idiot fights a war on two fronts. Only the heir to the throne of the kingdom of idiots would fight a war on twelve fronts. ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/4] console: expose consoles in devfs
On Fri, Feb 24, 2017 at 03:24:59PM +0100, Bastian Stender wrote: > This enables displaying text on e.g. a framebuffer console by issueing > > echo -o /dev/fbconsole0 abc123 > > Signed-off-by: Bastian Stender> --- > common/console.c | 52 > include/console.h | 3 +++ > 2 files changed, 55 insertions(+) > > diff --git a/common/console.c b/common/console.c > index 43890b3da8..dcd67afe20 100644 > --- a/common/console.c > +++ b/common/console.c > @@ -243,6 +243,39 @@ static int __console_puts(struct console_device *cdev, > const char *s) > return n; > } > > +static int fops_open(struct cdev *cdev, unsigned long flags) > +{ > + struct console_device *priv = cdev->priv; > + > + return priv->open(priv); > +} You do not check if this hook exists in the driver, but this will be solved when you follow what I suggested in 1/4. 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/4] console: replace set_active by open/close
On Fri, Feb 24, 2017 at 03:24:58PM +0100, Bastian Stender wrote: > Opening and closing consoles should be independent from setting them > active. This way it is possible to open e.g. a framebuffer console and > display text on it without showing stdout/stderr. > > Signed-off-by: Bastian Stender> --- > common/console.c | 19 +++ > drivers/video/fbconsole.c | 28 ++-- > include/console.h | 3 ++- > net/netconsole.c | 27 +-- > 4 files changed, 52 insertions(+), 25 deletions(-) > > diff --git a/common/console.c b/common/console.c > index 74ccfcfc3e..43890b3da8 100644 > --- a/common/console.c > +++ b/common/console.c > @@ -71,10 +71,21 @@ int console_set_active(struct console_device *cdev, > unsigned flag) > if (!flag && cdev->f_active && cdev->flush) > cdev->flush(cdev); > > - if (cdev->set_active) { > - ret = cdev->set_active(cdev, flag); > - if (ret) > - return ret; > + if (flag == cdev->f_active) > + return 0; > + > + if (!flag) { > + if (cdev->close) { > + ret = cdev->close(cdev); > + if (ret) > + return ret; > + } > + } else { > + if (cdev->open) { > + ret = cdev->open(cdev); > + if (ret) > + return ret; > + } > } instead of calling into cdev->open/close directly here I would prefer console_open() / console_close() functions which get called here. In these functions you can call the driver hooks on first open and last close. 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- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox