Raspberry Pi Sense HAT driver
Subsystems (6)
cover Raspberry Pi Sense HAT driver
This patch series adds a set of drivers for operating the Sense HAT peripheral device. This board is an add on for the Raspberry Pi that is designed to connect using the GPIO connector via I2C.
It features:
- a joystick
- an 8x8 RGB LED matrix display
- a whole bunch of environmental sensors with their own drivers (those are already in upstream Linux)
This is a refactor of the work of Serge Schneider, the author of a version of this driver that is currently in the Raspberry Pi downstream kernel. We modified his code to make it suitable for upstream Linux.
A couple of tests are available for the driver in this repo:
https://github.com/underground-software/sensehat/tree/master/tests
- color_test displays various solid colors on the LED panel
- framebuffer_test diplays a single lit cell that is controllable via the arrow keys or the joystick
For more information about the Sense HAT, visit:
https://www.raspberrypi.org/products/sense-hat/
Changes since v2:
- We included a device tree binding in yaml form
- Switched to regmap for all i2c communications
- Fixed a few places where we had the old rpisense name that we missed when renaming for v2
Charles Mirabile (5):
drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver drivers/input/joystick: sensehat: Raspberry Pi Sense HAT joystick
driver
drivers/auxdisplay: senshat: Raspberry Pi Sense HAT display driver
Documentation: bindings/mfd: sensehat: Raspberry Pi Sense HAT device
tree binding
MAINTAINERS: Add sensehat driver authors to MAINTAINERS
.../bindings/mfd/raspberrypi,sensehat.yaml | 50 ++++ MAINTAINERS | 11 + drivers/auxdisplay/Kconfig | 7 + drivers/auxdisplay/Makefile | 1 + drivers/auxdisplay/sensehat-display.c | 258 ++++++++++++++++++ drivers/input/joystick/Kconfig | 8 + drivers/input/joystick/Makefile | 1 + drivers/input/joystick/sensehat-joystick.c | 135 +++++++++ drivers/mfd/Kconfig | 8 + drivers/mfd/Makefile | 1 + drivers/mfd/sensehat-core.c | 164 +++++++++++ include/linux/mfd/sensehat.h | 64 +++++ 12 files changed, 708 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml create mode 100644 drivers/auxdisplay/sensehat-display.c create mode 100644 drivers/input/joystick/sensehat-joystick.c create mode 100644 drivers/mfd/sensehat-core.c create mode 100644 include/linux/mfd/sensehat.h
Signature · 1 line
2.31.1
PATCH 1/5 drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
This patch adds the core driver file, containing the regmap configuration needed to communicate with the board over I2C. We also add the header file shared by all three drivers, containing common data and definitions. In addition, we add a config option to toggle compilation of the driver.
--- drivers/mfd/Kconfig | 8 ++ drivers/mfd/Makefile | 1 + drivers/mfd/sensehat-core.c | 164 +++++++++++++++++++++++++++++++++++ include/linux/mfd/sensehat.h | 64 ++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 drivers/mfd/sensehat-core.c create mode 100644 include/linux/mfd/sensehat.h
drivers/mfd/Kconfig +8 -0
@@ -11,6 +11,14 @@ config MFD_CORE select IRQ_DOMAIN default n +config MFD_SENSEHAT_CORE + tristate "Raspberry Pi Sense HAT core functions" + depends on I2C + select MFD_CORE + help + This is the core driver for the Raspberry Pi Sense HAT. This provides + the necessary functions to communicate with the hardware. + config MFD_CS5535 tristate "AMD CS5535 and CS5536 southbridge core functions" select MFD_CORE
drivers/mfd/Makefile +1 -0
@@ -264,6 +264,7 @@ obj-$(CONFIG_MFD_ROHM_BD718XX) += rohm-bd718x7.o obj-$(CONFIG_MFD_ROHM_BD957XMUF) += rohm-bd9576.o obj-$(CONFIG_MFD_STMFX) += stmfx.o obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o +obj-$(CONFIG_MFD_SENSEHAT_CORE) += sensehat-core.o obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o
drivers/mfd/sensehat-core.c new file +164 -0
164 lines not on this page · raw message
include/linux/mfd/sensehat.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.31.1
kernel test robot
build botRe: [PATCH 1/5] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
Thank you for the patch! Yet something to improve:
Hi Charles,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on lee-mfd/for-mfd-next]
[also build test ERROR on dtor-input/next linux/master linus/master v5.15-rc7 next-20211029] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Charles-Mirabile/Raspberry-Pi-Sense-HAT-driver/20211030-055716 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ae7af468c4994435ae01c89e2b8ef53275a6b3b6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Charles-Mirabile/Raspberry-Pi-Sense-HAT-driver/20211030-055716 git checkout ae7af468c4994435ae01c89e2b8ef53275a6b3b6
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/mfd/sensehat-core.c:24:10: fatal error: sensehat.h: No such file or directory
24 | #include "sensehat.h"
| ^~~~~~~~~~~~compilation terminated.
vim +24 drivers/mfd/sensehat-core.c
> 24 #include "sensehat.h"
25 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH 1/5] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
In reply to Charles Mirabiledrivers/mfd/sensehat-core.c line 76
Quoted 7 lines · Charles Mirabile
drivers/mfd/sensehat-core.c new file +6
-0+static int sensehat_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ + + sensehat->joystick.pdev =sensehat_client_dev_register (sensehat, +"sensehat-joystick" );
Will this not fail the complete driver load if the driver for this single subdevice is not available?
For example if the Kconfig option has not been selected, the patch for the driver is not applied or the user has blacklisted the respective module in their system.
drivers/mfd/sensehat-core.c line 84
Quoted 7 lines
drivers/mfd/sensehat-core.c new file +7
-0+if (IS_ERR (sensehat->joystick.pdev)) { +dev_err (sensehat->dev,"failed to register sensehat-joystick" ); +return PTR_ERR (sensehat->joystick.pdev); + } + + sensehat->display.pdev =sensehat_client_dev_register (sensehat, +"sensehat-display" );
Same as above.
Quoted 27 lines
drivers/mfd/sensehat-core.c new file +27
-0+ +if (IS_ERR (sensehat->display.pdev)) { +dev_err (sensehat->dev,"failed to register sensehat-display" ); +return PTR_ERR (sensehat->display.pdev); + } + +return 0 ; +} + +static struct platform_device * +sensehat_client_dev_register (struct sensehat *sensehat,const char *name) +{ +long ret = -ENOMEM ; +struct platform_device *pdev =platform_device_alloc (name,-1 ); + +if (!pdev) + goto alloc_fail; + + pdev->dev.parent = sensehat->dev; +platform_set_drvdata (pdev, sensehat); + + ret =platform_device_add (pdev); +if (ret) + goto add_fail; + + ret =devm_add_action_or_reset (sensehat->dev, + (void *)platform_device_unregister, pdev);
drivers/mfd/sensehat-core.c line 121
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+if (ret) + goto alloc_fail; + +return pdev; + +add_fail: +platform_device_put (pdev); +alloc_fail: +return ERR_PTR (ret); +}
Thomas
Re: [PATCH 1/5] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
In reply to Charles MirabileQuoted 120 lines · Charles Mirabile
This patch adds the core driver file, containing the regmap configuration needed to communicate with the board over I2C. We also add the header file shared by all three drivers, containing common data and definitions. In addition, we add a config option to toggle compilation of the driver.
Signed-off-by Charles Mirabile <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Signed-off-by Joel Savitz <[email protected]>--- drivers/mfd/Kconfig | 8 ++ drivers/mfd/Makefile | 1 + drivers/mfd/sensehat-core.c | 164 +++++++++++++++++++++++++++++++++++ include/linux/mfd/sensehat.h | 64 ++++++++++++++ 4 files changed, 237 insertions(+)create mode 100644
drivers/mfd/sensehat-core.c
create mode 100644include/linux/mfd/sensehat.hdrivers/mfd/Kconfig +8
-0@@ -11,6 +11,14 @@ config MFD_CORE select IRQ_DOMAIN default n +config MFD_SENSEHAT_CORE + tristate "Raspberry Pi Sense HAT core functions" + depends on I2C + select MFD_CORE + help + This is the core driver for the Raspberry Pi Sense HAT. This provides + the necessary functions to communicate with the hardware. + config MFD_CS5535 tristate "AMD CS5535 and CS5536 southbridge core functions" select MFD_COREdrivers/mfd/Makefile +1
-0@@ -264,6 +264,7 @@ obj-$(CONFIG_MFD_ROHM_BD718XX) += rohm-bd718x7.o obj-$(CONFIG_MFD_ROHM_BD957XMUF) += rohm-bd9576.o obj-$(CONFIG_MFD_STMFX) += stmfx.o obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o +obj-$(CONFIG_MFD_SENSEHAT_CORE) += sensehat-core.o obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.odrivers/mfd/sensehat-core.c new file +66
-0@@ -0,0 +1,164 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Raspberry Pi Sense HAT core driver +* http://raspberrypi.org +* +* Copyright (C) 2015 Raspberry Pi +* Copyright (C) 2021 Charles Mirabile, Mwesigwa Guma, Joel Savitz +* +* Original Author: Serge Schneider +* Revised for upstream Linux by: Charles Mirabile, Mwesigwa Guma, Joel Savitz +* +* This driver is based on wm8350 implementation and was refactored to use the +* misc device subsystem rather than the deprecated framebuffer subsystem. +*/ + +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/i2c.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/regmap.h> +#include "sensehat.h" + +static struct platform_device * +sensehat_client_dev_register (struct sensehat *sensehat,const char *name); + +static struct regmap_config sensehat_config; + +static int sensehat_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ +int ret; +unsigned int reg; + +struct sensehat *sensehat =devm_kzalloc (&i2c->dev,sizeof (*sensehat),GFP_KERNEL ); + +if (!sensehat) +return -ENOMEM ; + +i2c_set_clientdata (i2c, sensehat); + sensehat->dev = &i2c->dev; + sensehat->i2c_client = i2c; + + sensehat->regmap =devm_regmap_init_i2c (sensehat->i2c_client, &sensehat_config); + +if (IS_ERR (sensehat->regmap)) { +dev_err (sensehat->dev,"Failed to initialize sensehat regmap" ); +return PTR_ERR (sensehat->regmap); + } + + + ret =regmap_read (sensehat->regmap,SENSEHAT_WAI , ®); +if (ret <0 ) { +dev_err (sensehat->dev,"failed to read from device" ); +return ret; + } + +if (reg !=SENSEHAT_ID ) { +dev_err (sensehat->dev,"expected device ID %i, got %i" , +SENSEHAT_ID , ret); +return -EINVAL ; + } + + ret =regmap_read (sensehat->regmap,SENSEHAT_VER , ®);
drivers/mfd/sensehat-core.c line 76
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+if (ret <0 ) { +dev_err (sensehat->dev,"Unable to get sensehat firmware version" ); +return ret; + } + +dev_info (sensehat->dev, +"Raspberry Pi Sense HAT firmware version %i\n" , reg); + + sensehat->joystick.pdev =sensehat_client_dev_register (sensehat, +"sensehat-joystick" );
Why don't you use devm_mfd_add_devices function together with mfd_cell?
Quoted 49 lines
drivers/mfd/sensehat-core.c new file +49
-0+ +if (IS_ERR (sensehat->joystick.pdev)) { +dev_err (sensehat->dev,"failed to register sensehat-joystick" ); +return PTR_ERR (sensehat->joystick.pdev); + } + + sensehat->display.pdev =sensehat_client_dev_register (sensehat, +"sensehat-display" ); + +if (IS_ERR (sensehat->display.pdev)) { +dev_err (sensehat->dev,"failed to register sensehat-display" ); +return PTR_ERR (sensehat->display.pdev); + } + +return 0 ; +} + +static struct platform_device * +sensehat_client_dev_register (struct sensehat *sensehat,const char *name) +{ +long ret = -ENOMEM ; +struct platform_device *pdev =platform_device_alloc (name,-1 ); + +if (!pdev) + goto alloc_fail; + + pdev->dev.parent = sensehat->dev; +platform_set_drvdata (pdev, sensehat); + + ret =platform_device_add (pdev); +if (ret) + goto add_fail; + + ret =devm_add_action_or_reset (sensehat->dev, + (void *)platform_device_unregister, pdev); +if (ret) + goto alloc_fail; + +return pdev; + +add_fail: +platform_device_put (pdev); +alloc_fail: +return ERR_PTR (ret); +} + +static bool sensehat_writeable_register (struct device *dev,unsigned int reg) +{ + return (reg >= SENSEHAT_DISPLAY &&
drivers/mfd/sensehat-core.c line 135
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+ reg < SENSEHAT_DISPLAY + sizeof(sensehat_fb_t)) + || reg ==SENSEHAT_EE_WP ; +} +static bool sensehat_readable_register (struct device *dev,unsigned int reg) +{ +return (reg >=SENSEHAT_DISPLAY && + reg <SENSEHAT_DISPLAY +sizeof (sensehat_fb_t)) + || reg ==SENSEHAT_WAI || reg ==SENSEHAT_VER + || reg ==SENSEHAT_KEYS || reg ==SENSEHAT_EE_WP ; +}
I wonder if we really need this. In the end this is tied to in kernel drivers. AFAIKS no userspace process can read. Without this we could move senhat_fb_t into the display driver as it's local to that driver.
Quoted 43 lines
drivers/mfd/sensehat-core.c new file +29
-0+ +static struct regmap_config sensehat_config = { + .name ="sensehat" , + .reg_bits =8 , + .val_bits =8 , + .writeable_reg = sensehat_writeable_register, + .readable_reg = sensehat_readable_register, +}; + +static const struct i2c_device_id sensehat_i2c_id[] = { + {"sensehat" ,0 }, + {"rpi-sense" ,0 }, + { } +}; +MODULE_DEVICE_TABLE (i2c, sensehat_i2c_id); + +static struct i2c_driver sensehat_driver = { + .driver = { + .name ="sensehat" , + }, + .probe = sensehat_probe, + .id_table = sensehat_i2c_id, +}; + +module_i2c_driver (sensehat_driver); + +MODULE_DESCRIPTION ("Raspberry Pi Sense HAT core driver" ); +MODULE_AUTHOR ("Serge Schneider <[email protected]>" ); +MODULE_LICENSE ("GPL" );include/linux/mfd/sensehat.h new file +8
-0@@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Raspberry Pi Sense HAT core driver +* http://raspberrypi.org +* +* Copyright (C) 2015 Raspberry Pi +* Copyright (C) 2021 Charles Mirabile, Mwesigwa Guma, Joel Savitz +*
include/linux/mfd/sensehat.h line 18
Quoted 10 lines
include/linux/mfd/sensehat.h new file +10
-0+* Original Author: Serge Schneider +* Revised for upstream Linux by: Charles Mirabile, Mwesigwa Guma, Joel Savitz +*/ + +#ifndef __LINUX_MFD_SENSEHAT_H_ +#define __LINUX_MFD_SENSEHAT_H_ +#include <linux/miscdevice.h> + +//8x8 display with 3 color channels +typedef u8 sensehat_fb_t [8 ][3 ][8 ];
I'm not a great fan of typedefs. AFAIK they are rarely used in kernel code.
Quoted 34 lines
include/linux/mfd/sensehat.h new file +34
-0+ +#define SENSEHAT_DISPLAY 0x00 +#define SENSEHAT_WAI 0xF0 +#define SENSEHAT_VER 0xF1 +#define SENSEHAT_KEYS 0xF2 +#define SENSEHAT_EE_WP 0xF3 + +#define SENSEHAT_ID 's' + +#define SENSEDISP_IOC_MAGIC 0xF1 + +#define SENSEDISP_IOGET_GAMMA _IO(SENSEDISP_IOC_MAGIC, 0) +#define SENSEDISP_IOSET_GAMMA _IO(SENSEDISP_IOC_MAGIC, 1) +#define SENSEDISP_IORESET_GAMMA _IO(SENSEDISP_IOC_MAGIC, 2) + +struct sensehat { + struct device *dev; + struct i2c_client *i2c_client; + struct regmap *regmap; + + /* Client devices */ + struct sensehat_joystick { + struct platform_device *pdev; + struct input_dev *keys_dev; + struct gpio_desc *keys_desc; + int keys_irq; + } joystick; + + struct sensehat_display { + struct platform_device *pdev; + struct miscdevice mdev; + struct mutex rw_mtx; + u8 gamma[32]; + struct {
include/linux/mfd/sensehat.h line 62
Quoted 10 lines
include/linux/mfd/sensehat.h new file +10
-0+ u16 b:5, u:1, g:5, r:5; + } vmem[8 ][8 ]; + } display; +}; + +enum gamma_preset { +GAMMA_DEFAULT =0 , +GAMMA_LOWLIGHT , +GAMMA_PRESET_COUNT , +};
Please review, which of this defines really need to be in the header and can't be just local to the corresponding driver.
Apart from that, I'd appreciate if you could add me in CC in the next version of this patches. I also wonder why you didn't CC arm-linux-kernel mailinglist, in the end this is a board for RPi and hence Arm.
Regards,
Matthias
Quoted 3 lines
include/linux/mfd/sensehat.h new file +2
-0+ +#endif
Re: [PATCH 1/5] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
Quoted 5 lines · Matthias Brugger
drivers/mfd/sensehat-core.c line 76
Quoted 3 lines
drivers/mfd/sensehat-core.c new file +3
-0+ + sensehat->joystick.pdev =sensehat_client_dev_register (sensehat, +"sensehat-joystick" );Why don't you use
devm_mfd_add_devicesfunction together withmfd_cell?
To complete Matthias' comment, why not use simple-mfd-i2c?
Signature · 1 line
Nicolás Sáenz
PATCH 2/5 drivers/input/joystick: sensehat: Raspberry Pi Sense HAT joystick driver
In reply to Charles MirabileThis patch implements support for the joystick.
It supports left/right/up/down/enter and is
attached via i2c and a gpio pin for irq.
--- drivers/input/joystick/Kconfig | 8 ++ drivers/input/joystick/Makefile | 1 + drivers/input/joystick/sensehat-joystick.c | 135 +++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 drivers/input/joystick/sensehat-joystick.c
drivers/input/joystick/Kconfig +8 -0
@@ -399,4 +399,12 @@ config JOYSTICK_N64 Say Y here if you want enable support for the four built-in controller ports on the Nintendo 64 console. +config JOYSTICK_SENSEHAT + tristate "Raspberry Pi Sense HAT joystick" + depends on GPIOLIB && INPUT + select MFD_SENSEHAT_CORE + + help + This is the joystick driver for the Raspberry Pi Sense HAT + endif
drivers/input/joystick/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_JOYSTICK_N64) += n64joy.o obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o obj-$(CONFIG_JOYSTICK_QWIIC) += qwiic-joystick.o +obj-$(CONFIG_JOYSTICK_SENSEHAT) += sensehat-joystick.o obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o obj-$(CONFIG_JOYSTICK_SPACEORB) += spaceorb.o
drivers/input/joystick/sensehat-joystick.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH 2/5] drivers/input/joystick: sensehat: Raspberry Pi Sense HAT joystick driver
Quoted 19 lines · Charles Mirabile
This patch implements support for the joystick. It supports left/right/up/down/enter and is attached via i2c and a gpio pin for irq.
Signed-off-by Charles Mirabile <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Signed-off-by Joel Savitz <[email protected]>--- drivers/input/joystick/Kconfig | 8 ++ drivers/input/joystick/Makefile | 1 + drivers/input/joystick/sensehat-joystick.c | 135 +++++++++++++++++++++ 3 files changed, 144 insertions(+)create mode 100644
drivers/input/joystick/sensehat-joystick.cdrivers/input/joystick/Kconfig +0
-0
drivers/input/joystick/Kconfig config JOYSTICK_N64 · line 404
Quoted 6 lines
drivers/input/joystick/Kconfig +3
-0@@ -399,4 +399,12 @@ config JOYSTICK_N64 Say Y here if you want enable support for the four built-in controller ports on the Nintendo 64 console. +config JOYSTICK_SENSEHAT + tristate "Raspberry Pi Sense HAT joystick" + depends on GPIOLIB && INPUT
I think also:
depends on I2C
since this one:
drivers/input/joystick/Kconfig config JOYSTICK_N64 · line 405
Quoted 1 line
drivers/input/joystick/Kconfig +1
-0+ select MFD_SENSEHAT_CORE
also depends on I2C and 'select' does not follow any dependency chains.
Same comment applies to patch 3/5 for SENSEHAT_DISPLAY.
Quoted 5 lines
drivers/input/joystick/Kconfig +4
-0+ + help + This is the joystick driver for the Raspberry Pi Sense HAT + endif
Signature · 1 line
~Randy
kernel test robot
build botRe: [PATCH 2/5] drivers/input/joystick: sensehat: Raspberry Pi Sense HAT joystick driver
In reply to Charles MirabileThank you for the patch! Yet something to improve:
Hi Charles,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on lee-mfd/for-mfd-next]
[also build test ERROR on dtor-input/next linux/master linus/master v5.15-rc7 next-20211029] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Charles-Mirabile/Raspberry-Pi-Sense-HAT-driver/20211030-055716 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/0a53172779554b2a11dd6a8a372fd942e801bc60
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Charles-Mirabile/Raspberry-Pi-Sense-HAT-driver/20211030-055716 git checkout 0a53172779554b2a11dd6a8a372fd942e801bc60
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/input/joystick/sensehat-joystick.c:21:10: fatal error: sensehat.h: No such file or directory
21 | #include "sensehat.h"
| ^~~~~~~~~~~~compilation terminated.
vim +21 drivers/input/joystick/sensehat-joystick.c
20
> 21 #include "sensehat.h"
22 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 3/5 drivers/auxdisplay: senshat: Raspberry Pi Sense HAT display driver
In reply to Charles MirabileThis patch implements control of the 8x8 RGB LED matrix display.
--- drivers/auxdisplay/Kconfig | 7 + drivers/auxdisplay/Makefile | 1 + drivers/auxdisplay/sensehat-display.c | 258 ++++++++++++++++++++++++++ 3 files changed, 266 insertions(+) create mode 100644 drivers/auxdisplay/sensehat-display.c
drivers/auxdisplay/Kconfig +7 -0
@@ -193,6 +193,13 @@ config ARM_CHARLCD line and the Linux version on the second line, but that's still useful. +config SENSEHAT_DISPLAY + tristate "Raspberry pi Sense HAT display driver" + select MFD_SENSEHAT_CORE + help + This is a driver for the Raspberry Pi Sensehat 8x8 RBG-LED matrix + you can access it as a misc device at /dev/sense-hat + menuconfig PARPORT_PANEL tristate "Parallel port LCD/Keypad Panel support" depends on PARPORT
drivers/auxdisplay/Makefile +1 -0
@@ -13,3 +13,4 @@ obj-$(CONFIG_HD44780) += hd44780.o obj-$(CONFIG_HT16K33) += ht16k33.o obj-$(CONFIG_PARPORT_PANEL) += panel.o obj-$(CONFIG_LCD2S) += lcd2s.o +obj-$(CONFIG_SENSEHAT_DISPLAY) += sensehat-display.o
drivers/auxdisplay/sensehat-display.c new file +257 -0
257 lines not on this page · raw message
Signature · 1 line
2.31.1
kernel test robot
build botRe: [PATCH 3/5] drivers/auxdisplay: senshat: Raspberry Pi Sense HAT display driver
Thank you for the patch! Yet something to improve:
Hi Charles,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on lee-mfd/for-mfd-next]
[also build test ERROR on dtor-input/next linux/master linus/master v5.15-rc7] [cannot apply to next-20211029]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Charles-Mirabile/Raspberry-Pi-Sense-HAT-driver/20211030-055716 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7bfd5f3b8be9618031188098c3e85930ea59844e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Charles-Mirabile/Raspberry-Pi-Sense-HAT-driver/20211030-055716 git checkout 7bfd5f3b8be9618031188098c3e85930ea59844e
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/auxdisplay/sensehat-display.c:26:10: fatal error: sensehat.h: No such file or directory
26 | #include "sensehat.h"
| ^~~~~~~~~~~~compilation terminated.
vim +26 drivers/auxdisplay/sensehat-display.c
25
> 26 #include "sensehat.h"
27 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH 3/5] drivers/auxdisplay: senshat: Raspberry Pi Sense HAT display driver
In reply to Charles MirabileQuoted 12 lines · Charles Mirabile
This patch implements control of the 8x8 RGB LED matrix display.
Signed-off-by Charles Mirabile <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Signed-off-by Joel Savitz <[email protected]>--- drivers/auxdisplay/Kconfig | 7 + drivers/auxdisplay/Makefile | 1 + drivers/auxdisplay/sensehat-display.c | 258 ++++++++++++++++++++++++++ 3 files changed, 266 insertions(+)create mode 100644
drivers/auxdisplay/sensehat-display.c
[....]
Quoted 5 lines
drivers/auxdisplay/sensehat-display.c new file +0
-0
[...]
Quoted 7 lines
drivers/auxdisplay/sensehat-display.c new file +7
-0+ +static ssize_t +sensehat_display_write (struct file *filp,const char __user *buf,size_t count,loff_t *f_pos) +{ + struct sensehat *sensehat = container_of(filp->private_data, struct sensehat, display.mdev); +struct sensehat_display *sensehat_display = &sensehat->display; +u8 temp[VMEM_SIZE ];
drivers/auxdisplay/sensehat-display.c line 157
Quoted 10 lines
drivers/auxdisplay/sensehat-display.c new file +10
-0+ +if (*f_pos >=VMEM_SIZE ) +return -EFBIG ; +if (*f_pos + count >VMEM_SIZE ) + count =VMEM_SIZE - *f_pos; +if (copy_from_user (temp, buf, count)) +return -EFAULT ; +if (mutex_lock_interruptible (&sensehat_display->rw_mtx)) +return -ERESTARTSYS ; +memcpy (sensehat_display->vmem + *f_pos, temp, count);
So we copy from buf into temp, from temp into vmem and then we 'transform' vmem into the representation of pixel_data.
As you are implementing the user-space interface, couldn't we just change the pixel representation there and get rid of the transformation?
Quoted 22 lines
drivers/auxdisplay/sensehat-display.c new file +22
-0+sensehat_update_display (sensehat); + *f_pos += count; +mutex_unlock (&sensehat_display->rw_mtx); +return count; +} + +static long sensehat_display_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg) +{ + struct sensehat *sensehat = container_of(filp->private_data, struct sensehat, display.mdev); +struct sensehat_display *sensehat_display = &sensehat->display; +void __user *user_ptr = (void __user *)arg; +u8 temp[GAMMA_SIZE ]; +int ret; + +if (mutex_lock_interruptible (&sensehat_display->rw_mtx)) +return -ERESTARTSYS ; +switch (cmd) { +case SENSEDISP_IOGET_GAMMA : +if (copy_to_user (user_ptr, sensehat_display->gamma,GAMMA_SIZE )) { + ret = -EFAULT ; + goto out_unlock;
drivers/auxdisplay/sensehat-display.c line 189
Quoted 10 lines
drivers/auxdisplay/sensehat-display.c new file +10
-0+ } + ret =0 ; + goto out_unlock; +case SENSEDISP_IOSET_GAMMA : +if (copy_from_user (temp, user_ptr,GAMMA_SIZE )) { + ret = -EFAULT ; + goto out_unlock; + } + ret =0 ; + goto out_update;
That's just a 'break;' correct?
Regards,
Matthias
PATCH 4/5 Documentation: bindings/mfd: sensehat: Raspberry Pi Sense HAT device tree binding
In reply to Charles MirabileThis patch adds the device tree binding
for the Sense HAT in yaml form.
--- .../bindings/mfd/raspberrypi,sensehat.yaml | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml new file +51 -0
@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +$id: http://devicetree.org/schemas/mfd/raspberrypi,sensehat.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Raspberry Pi Sensehat + +maintainers: + - Charles Mirabile <[email protected]> + - Mwesigwa Guma <[email protected]> + - Joel Savitz <[email protected]> + +description: | + The Raspberry Pi Sensehat is an addon board originally developed + for the Raspberry Pi that has a joystick and an 8x8 RGB LED display + as well as several environmental sensors. It connects via i2c and + a gpio for irq. + +properties: + compatible: + oneOf: + - enum: + - raspberrypi,sensehat + - rpi,rpisense + + reg: + items: + - description: i2c bus address + + keys-int-gpios: + items: + - description: gpio pin for joystick interrupt + +required: + - compatible + - reg + - keys-int-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + sensehat@46 { + compatible = "raspberrypi,sensehat"; + reg = <0x46>; + keys-int-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>; + }; + };
Signature · 1 line
2.31.1
Rob Herring
maintainerRe: [PATCH 4/5] Documentation: bindings/mfd: sensehat: Raspberry Pi Sense HAT device tree binding
Quoted 2 lines · Charles Mirabile
This patch adds the device tree binding
for the Sense HAT in yaml form.
For the subject, follow the format of the subsystem (run git log --oneline) and no need to say 'binding' multiple times:
dt-bindings: mfd: Add Raspberry Pi Sense HAT schema
Quoted 17 lines
Signed-off-by Charles Mirabile <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Signed-off-by Joel Savitz <[email protected]>--- .../bindings/mfd/raspberrypi,sensehat.yaml | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yamlDocumentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml new file +2
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +$id: http://devicetree.org/schemas/mfd/raspberrypi,sensehat.yaml#
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml new file +10
-0+$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Raspberry Pi Sensehat + +maintainers: + - Charles Mirabile <[email protected]> + - Mwesigwa Guma <[email protected]> + - Joel Savitz <[email protected]> + +description: |
'|' is not needed if there is no formatting to preserve.
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml line 21
Quoted 9 lines
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml new file +9
-0+ The Raspberry Pi Sensehat is an addon board originally developed + for the Raspberry Pi that has a joystick and an 8x8 RGB LED display + as well as several environmental sensors. It connects via i2c and + a gpio for irq. + +properties: + compatible: + oneOf: + - enum:
Don't need oneOf when there is only one entry.
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml line 23
Quoted 2 lines
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml new file +2
-0+ - raspberrypi,sensehat + - rpi,rpisense
'rpi' is not a vendor prefix.
What's the fallback for anyways?
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml line 31
Quoted 8 lines
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml new file +8
-0+ + reg: + items: + - description: i2c bus address + + keys-int-gpios: + items: + - description: gpio pin for joystick interrupt
For an interrupt, use 'interrupts'.
Quoted 24 lines
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml new file +20
-0+ +required: + - compatible + - reg + - keys-int-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + sensehat@46 { + compatible = "raspberrypi,sensehat"; + reg = <0x46>; + keys-int-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>; + }; + };Signature · 1 line
2.31.1
PATCH 5/5 MAINTAINERS: Add sensehat driver authors to MAINTAINERS
In reply to Charles MirabileThis patch adds the driver authors to MAINAINERS.
--- MAINTAINERS | 11 +++++++++++ 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
@@ -16882,6 +16882,17 @@ S: Maintained F: drivers/misc/phantom.c F: include/uapi/linux/phantom.h +SENSEHAT DRIVER +M: Charles Mirabile <[email protected]> +M: Mwesigwa Guma <[email protected]> +M: Joel Savitz <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml +F: drivers/auxdisplay/sensehat-display.c +F: drivers/input/joystick/sensehat-joystick.c +F: drivers/mfd/sensehat-core.c +F: include/linux/mfd/sensehat.h + SENSIRION SCD30 CARBON DIOXIDE SENSOR DRIVER M: Tomasz Duszynski <[email protected]> S: Maintained
Signature · 1 line
2.31.1
Quoted 4 lines · Charles Mirabile
Signed-off-by Charles Mirabile <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Signed-off-by Joel Savitz <[email protected]>
Please note that you need to write Co-developed-by: ... (see Documentation/process/submitting-patches.rst); otherwise, it looks as if this was sent through several layers.
Cheers,
Miguel
Thanks for the suggestion, we weren't sure what the right "Xxx-by:" was for this circumstance so we will use this in subsequent patchsets.
Best,
Joel Savitz
Best,
Joel Savitz
Quoted 14 lines · Miguel Ojeda
Quoted 4 lines · Charles Mirabile
Signed-off-by Charles Mirabile <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Signed-off-by Joel Savitz <[email protected]>Please note that you need to write
Co-developed-by: ...(seeDocumentation/process/submitting-patches.rst); otherwise, it looks as if this was sent through several layers.Cheers,
Miguel
Hi,
Am 29.10.21 um 23:55 schrieb Charles Mirabile:
Quoted 20 lines
This patch series adds a set of drivers for operating the Sense HAT peripheral device. This board is an add on for the Raspberry Pi that is designed to connect using the GPIO connector via I2C.
It features:
- a joystick
- an 8x8 RGB LED matrix display
- a whole bunch of environmental sensors with their own drivers (those are already in upstream Linux)This is a refactor of the work of Serge Schneider, the author of a version of this driver that is currently in the Raspberry Pi downstream kernel. We modified his code to make it suitable for upstream Linux.
A couple of tests are available for the driver in this repo:
https://github.com/underground-software/sensehat/tree/master/tests
-color_testdisplays various solid colors on the LED panel
-framebuffer_testdiplays a single lit cell that is controllable via the arrow keys or the joystick
Quoted 8 lines
For more information about the Sense HAT, visit:
https://www.raspberrypi.org/products/sense-hat/Changes since v2:
- We included a device tree binding in yaml form
- Switched to regmap for all i2c communications
- Fixed a few places where we had the old rpisense name that we missed when renaming for v2
since this is V2 of the patch series, please mark this properly in all subjects:
[PATCH V2 0/5] ...
Otherwise this is a nightmare for reviewers and maintainers.
Best regards