Raspberry Pi Sense HAT driver
Subsystems (6)
v5 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 displays 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/
Issues fixed since v4:
- Removed the regmap readable/writeable register functions because they necessitated putting lots of internal details in the header. Moved those details back into .c files (Thanks to Matthias Brugger for the suggestion).
- Added ifdef blocks to only attempt to register the children devices the user wants according to kconfig (Thanks to Thomas Weißschuh for the suggestion).
- Corrected kconfig dependencies for joystick and display so that they now also depend on i2c being enabled (Thanks to Randy Dunlap for the suggestion).
- Simplified the control flow in display ioctl (Thanks to Matthias Brugger for the suggestion).
- Signed off on the patch sets correctly with co-developed-by (Thanks to Miguel Ojeda for the correction).
Improvements since v4:
- Removed fallback compatible string from downstream overlay and having dropped support for it, wrote a new overlay and binding that uses the interrupt and interrupt-parent properties as opposed to a downstream hack, thus simplifying the registration logic for joystick (Thanks to Rob Herring for the suggestion).
Suggestions from v4 not addressed yet:
- Use mfd_cells for the joystick and display platform devices (as suggested by Matthias Brugger) or remove sensehat-core.c entirely and use simple-mfd-i2c instead (as suggested by Nicolás Sáenz Julienne).
- while these suggestions might make great improvements for a version two of the driver they would require a large rewrite to move all of the complexity in core elsewhere. While certainly possible and something we want to iterate on and achieve eventually, we think saving it for down the road makes sense at this time.
- Modify the userspace interface of the display driver so it matches the internal representation used by the uC on the other end of the wire to try and eliminate the overhead of reformatting it.
- The format is still compatible with the downstream version of this driver meaning that porting existing applications for the sensehat to work with this driver is currently trivial. Changing this interface would make it less so. Although certainly not impossible, it is a downside to be considered.
- The "complexity" of unpacking the bit packed the data is a current cost, but it has the added benefit of automatically restricting the values to 0-31. New logic would need to be added to clamp or wrap out of bounds values that might be just as expensive.
Charles Mirabile (6):
drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver drivers/input/joystick: sensehat: Raspberry Pi Sense HAT joystick
driver
drivers/auxdisplay: sensehat: Raspberry Pi Sense HAT display driver
dt-bindings: mfd: sensehat: Raspberry Pi Sense HAT schema
MAINTAINERS: Add sensehat driver authors to MAINTAINERS DO NOT MERGE: full sensehat device tree overlay for raspberry pi 4
.../bindings/mfd/raspberrypi,sensehat.yaml | 54 ++++ MAINTAINERS | 11 + drivers/auxdisplay/Kconfig | 8 + drivers/auxdisplay/Makefile | 1 + drivers/auxdisplay/sensehat-display.c | 268 ++++++++++++++++++ drivers/input/joystick/Kconfig | 8 + drivers/input/joystick/Makefile | 1 + drivers/input/joystick/sensehat-joystick.c | 119 ++++++++ drivers/mfd/Kconfig | 8 + drivers/mfd/Makefile | 1 + drivers/mfd/sensehat-core.c | 157 ++++++++++ include/linux/mfd/sensehat.h | 51 ++++ sensehat.dtbs | 44 +++ 13 files changed, 731 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 create mode 100644 sensehat.dtbs
Signature · 1 line
2.31.1
PATCH v5 1/6 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 | 157 +++++++++++++++++++++++++++++++++++ include/linux/mfd/sensehat.h | 51 ++++++++++++ 4 files changed, 217 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
@@ -263,6 +263,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 +157 -0
157 lines not on this page · raw message
include/linux/mfd/sensehat.h new file +51 -0
51 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH V5 1/6] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
Hi,
Currently this patch already contains some code that is only needed by the patches adding the actual subdrivers.
I marked them below.
If you are resubmitting this code should be moved to the respective subdriver patch.
Quoted 146 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]>Co-developed-by Mwesigwa Guma <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Co-developed-by Joel Savitz <[email protected]>Signed-off-by Joel Savitz <[email protected]>--- drivers/mfd/Kconfig | 8 ++ drivers/mfd/Makefile | 1 + drivers/mfd/sensehat-core.c | 157 +++++++++++++++++++++++++++++++++++ include/linux/mfd/sensehat.h | 51 ++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 drivers/mfd/sensehat-core.c create mode 100644 include/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@@ -263,6 +263,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 +90
-0@@ -0,0 +1,157 @@ +// 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 <linux/mfd/sensehat.h> + +#define SENSEHAT_WAI 0xF0 +#define SENSEHAT_VER 0xF1 + +#define SENSEHAT_ID 's' + +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 , ®); +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); + +#ifdef CONFIG_JOYSTICK_SENSEHAT + sensehat->joystick.pdev = +sensehat_client_dev_register (sensehat,"sensehat-joystick" ); + +if (IS_ERR (sensehat->joystick.pdev)) { +dev_err (sensehat->dev,"failed to register sensehat-joystick" ); +return PTR_ERR (sensehat->joystick.pdev); + } +#endif
drivers/mfd/sensehat-core.c line 100
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+#ifdef CONFIG_SENSEHAT_DISPLAY + + 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); + } +#endif
These two ifdef blocks.
Quoted 74 lines
drivers/mfd/sensehat-core.c new file +57
-0+ +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,PLATFORM_DEVID_AUTO ); + +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 struct regmap_config sensehat_config = { + .name ="sensehat" , + .reg_bits =8 , + .val_bits =8 , +}; + +static const struct i2c_device_id sensehat_i2c_id[] = { + { .name ="sensehat" }, + {}, +}; +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 +11
-0@@ -0,0 +1,51 @@ +/* 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 +*/
include/linux/mfd/sensehat.h line 21
Quoted 10 lines
include/linux/mfd/sensehat.h new file +10
-0+ +#ifndef __LINUX_MFD_SENSEHAT_H_ +#define __LINUX_MFD_SENSEHAT_H_ +#include <linux/miscdevice.h> + +#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)
These defines.
Quoted 10 lines
include/linux/mfd/sensehat.h new file +10
-0+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; + } joystick;
include/linux/mfd/sensehat.h line 42
Quoted 10 lines
include/linux/mfd/sensehat.h new file +10
-0+ +struct sensehat_display { +struct platform_device *pdev; +struct miscdevice mdev; +struct mutex rw_mtx; +u8 gamma[32 ]; +struct { +u16 b :5 , u :1 , g :5 , r :5 ; + } vmem[8 ][8 ]; + } display;
These two substructs.
include/linux/mfd/sensehat.h line 49
Quoted 7 lines
include/linux/mfd/sensehat.h new file +7
-0+}; + +enum gamma_preset { +GAMMA_DEFAULT =0 , +GAMMA_LOWLIGHT , +GAMMA_PRESET_COUNT , +};
This enum.
Quoted 5 lines
include/linux/mfd/sensehat.h new file +2
-0+ +#endif Signature · 1 line
2.31.1
Re: [PATCH V5 1/6] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
In reply to Charles MirabileAm 10.12.21 um 23:10 schrieb Charles Mirabile:
Quoted 19 lines
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]>Co-developed-by Mwesigwa Guma <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Co-developed-by Joel Savitz <[email protected]>Signed-off-by Joel Savitz <[email protected]>--- drivers/mfd/Kconfig | 8 ++ drivers/mfd/Makefile | 1 + drivers/mfd/sensehat-core.c | 157 +++++++++++++++++++++++++++++++++++ include/linux/mfd/sensehat.h | 51 ++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 drivers/mfd/sensehat-core.c create mode 100644 include/linux/mfd/sensehat.h
...
Quoted 13 lines
drivers/mfd/sensehat-core.c new file +7
-0@@ -0,0 +1,157 @@ +// 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
drivers/mfd/sensehat-core.c line 17
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+* +* 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>
Is this header really necessary?
Quoted 5 lines
drivers/mfd/sensehat-core.c new file +5
-0+#include <linux/err.h> +#include <linux/init.h> +#include <linux/i2c.h> +#include <linux/platform_device.h> +#include <linux/slab.h>
drivers/mfd/sensehat-core.c line 32
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+#include <linux/regmap.h> +#include <linux/mfd/sensehat.h> + +#define SENSEHAT_WAI 0xF0 +#define SENSEHAT_VER 0xF1 + +#define SENSEHAT_ID 's' + +static struct platform_device * +sensehat_client_dev_register (struct sensehat *sensehat,const char *name);
Please avoid this forward declaration
drivers/mfd/sensehat-core.c line 34
Quoted 2 lines
drivers/mfd/sensehat-core.c new file +2
-0+ +static struct regmap_config sensehat_config;
Is there a specific reason, why the driver only supports one sense hat?
Quoted 18 lines
drivers/mfd/sensehat-core.c new file +18
-0+ +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 =
drivers/mfd/sensehat-core.c line 62
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+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" );
I think the return code of regmap_read could be helpful in the log entry.
Quoted 18 lines
drivers/mfd/sensehat-core.c new file +18
-0+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 , ®); +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);
drivers/mfd/sensehat-core.c line 90
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+ +#ifdef CONFIG_JOYSTICK_SENSEHAT + sensehat->joystick.pdev = +sensehat_client_dev_register (sensehat,"sensehat-joystick" ); + +if (IS_ERR (sensehat->joystick.pdev)) { +dev_err (sensehat->dev,"failed to register sensehat-joystick" ); +return PTR_ERR (sensehat->joystick.pdev); + } +#endif
Please replace the #ifdev blocks with IS_ENABLED() to increase compile coverage
Re: [PATCH V5 1/6] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
In reply to Charles MirabileHi Charles,
Quoted 126 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]>Co-developed-by Mwesigwa Guma <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Co-developed-by Joel Savitz <[email protected]>Signed-off-by Joel Savitz <[email protected]>--- drivers/mfd/Kconfig | 8 ++ drivers/mfd/Makefile | 1 + drivers/mfd/sensehat-core.c | 157 +++++++++++++++++++++++++++++++++++ include/linux/mfd/sensehat.h | 51 ++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 drivers/mfd/sensehat-core.c create mode 100644 include/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@@ -263,6 +263,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 +70
-0@@ -0,0 +1,157 @@ +// 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 <linux/mfd/sensehat.h> + +#define SENSEHAT_WAI 0xF0 +#define SENSEHAT_VER 0xF1 + +#define SENSEHAT_ID 's' + +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 ; + }
drivers/mfd/sensehat-core.c line 80
Quoted 10 lines
drivers/mfd/sensehat-core.c new file +10
-0+ + ret =regmap_read (sensehat->regmap,SENSEHAT_VER , ®); +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);
I think both these sections and sensehat_client_dev_register() could be avoided with a properly configured struct mfd_cell and a call to devm_mfd_add_devices(). Actually, you're not making use of the mfd subsystem at all in this driver, which is odd. For an example see 'drivers/mfd/mp2629.c'.
It's easy to get all these device registration operations wrong, so it's always perfered to use the subsytem facilities when available.
Quoted 77 lines
drivers/mfd/sensehat-core.c new file +77
-0+ +#ifdef CONFIG_JOYSTICK_SENSEHAT + sensehat->joystick.pdev = +sensehat_client_dev_register (sensehat,"sensehat-joystick" ); + +if (IS_ERR (sensehat->joystick.pdev)) { +dev_err (sensehat->dev,"failed to register sensehat-joystick" ); +return PTR_ERR (sensehat->joystick.pdev); + } +#endif +#ifdef CONFIG_SENSEHAT_DISPLAY + + 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); + } +#endif + +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,PLATFORM_DEVID_AUTO ); + +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 struct regmap_config sensehat_config = { + .name ="sensehat" , + .reg_bits =8 , + .val_bits =8 , +}; + +static const struct i2c_device_id sensehat_i2c_id[] = { + { .name ="sensehat" }, + {}, +}; +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" );
Signature · 1 line
Nicolás Sáenz
PATCH v5 2/6 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 | 119 +++++++++++++++++++++ 3 files changed, 128 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 && I2C + 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 +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.31.1
Dmitry Torokhov
maintainerRe: [PATCH V5 2/6] drivers/input/joystick: sensehat: Raspberry Pi Sense HAT joystick driver
Hi Charles,
Quoted 3 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.
This is not really a joystick, at least not in current incarnation, but rather a set of keys. I'd also question whether the selected set is right for the application, I'd look into BTN_DPAD_* maybe?
Or, if you want it to be a joystick, map ABS_X/ABS_Y.
Quoted 18 lines
Signed-off-by Charles Mirabile <[email protected]>Co-developed-by Mwesigwa Guma <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Co-developed-by Joel Savitz <[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 | 119 +++++++++++++++++++++ 3 files changed, 128 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 && I2C
I do not see I2C accessed directly in this driver, nor GPIO interface. You also do not need to depend on INPUT explicitly here.
Quoted 29 lines
drivers/input/joystick/Kconfig +5
-0+ select MFD_SENSEHAT_CORE + + help + This is the joystick driver for the Raspberry Pi Sense HAT + endifdrivers/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.odrivers/input/joystick/sensehat-joystick.c new file +5
-0@@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Raspberry Pi Sense HAT joystick driver +* http://raspberrypi.org +*
drivers/input/joystick/sensehat-joystick.c line 15
Quoted 10 lines
drivers/input/joystick/sensehat-joystick.c new file +10
-0+* 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 +*/ + +#include <linux/module.h> +#include <linux/input.h> +#include <linux/i2c.h>
Don't think you need this.
drivers/input/joystick/sensehat-joystick.c line 17
Quoted 2 lines
drivers/input/joystick/sensehat-joystick.c new file +2
-0+#include <linux/interrupt.h> +#include <linux/gpio/consumer.h>
Not needed.
drivers/input/joystick/sensehat-joystick.c line 28
Quoted 11 lines
drivers/input/joystick/sensehat-joystick.c new file +11
-0+#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/mfd/sensehat.h> + +#define SENSEHAT_KEYS 0xF2 + +static int sensehat_get_joystick_state (struct sensehat *sensehat); + +static unsigned char keymap[] = { +KEY_DOWN ,KEY_RIGHT ,KEY_UP ,KEY_ENTER ,KEY_LEFT , +};
Because you allowing manipulating keymap from userspace you need to make a copy of it when setting up input device so that changes do would not persist across bind/unbind.
This array needs to be marked const.
Quoted 7 lines
drivers/input/joystick/sensehat-joystick.c new file +7
-0+ +static irqreturn_t sensehat_joystick_report (int n,void *cookie) +{ +int i; +static s32 prev_keys; +struct sensehat *sensehat = cookie; +struct sensehat_joystick *sensehat_joystick = &sensehat->joystick;
drivers/input/joystick/sensehat-joystick.c line 45
Quoted 10 lines
drivers/input/joystick/sensehat-joystick.c new file +10
-0+s32 keys =sensehat_get_joystick_state (sensehat); +s32 changes = keys ^ prev_keys; + + prev_keys = keys; +for (i =0 ; i <ARRAY_SIZE (keymap); ++i) { +if (changes & (1 << i)) { +input_report_key (sensehat_joystick->keys_dev, keymap[i], + keys & (1 << i)); + } + }
If you go with keys/buttons approach, then use bitmap_xor()/for_each_set_bit() - see drivers/input/keyboard/cypress-sf.c::cypress_sf_irq_handler() for example of use.
drivers/input/joystick/sensehat-joystick.c line 52
Quoted 7 lines
drivers/input/joystick/sensehat-joystick.c new file +7
-0+input_sync (sensehat_joystick->keys_dev); +return IRQ_HANDLED ; +} + +static int sensehat_joystick_probe (struct platform_device *pdev) +{ +int ret;
Please call it "error";
drivers/input/joystick/sensehat-joystick.c line 55
Quoted 3 lines
drivers/input/joystick/sensehat-joystick.c new file +3
-0+int i; +struct sensehat *sensehat =dev_get_drvdata (&pdev->dev); +struct sensehat_joystick *sensehat_joystick = &sensehat->joystick;
This structure (struct sensehat_joystick) should probably be private to this driver.
Quoted 19 lines
drivers/input/joystick/sensehat-joystick.c new file +19
-0+ + sensehat_joystick->keys_dev =devm_input_allocate_device (&pdev->dev); +if (!sensehat_joystick->keys_dev) { +dev_err (&pdev->dev,"Could not allocate input device.\n" ); +return -ENOMEM ; + } + +for (i =0 ; i <ARRAY_SIZE (keymap); i++) { +set_bit (keymap[i], sensehat_joystick->keys_dev->keybit); + } + + sensehat_joystick->keys_dev->name ="Raspberry Pi Sense HAT Joystick" ; + sensehat_joystick->keys_dev->phys ="rpi-sense-joy/input0" ; + sensehat_joystick->keys_dev->id.bustype =BUS_I2C ; + sensehat_joystick->keys_dev->evbit[0 ] = +BIT_MASK (EV_KEY ) |BIT_MASK (EV_REP ); + sensehat_joystick->keys_dev->keycode = keymap; + sensehat_joystick->keys_dev->keycodesize =sizeof (unsigned char ); + sensehat_joystick->keys_dev->keycodemax =ARRAY_SIZE (keymap);
drivers/input/joystick/sensehat-joystick.c line 84
Quoted 10 lines
drivers/input/joystick/sensehat-joystick.c new file +10
-0+ + ret =input_register_device (sensehat_joystick->keys_dev); +if (ret) { +dev_err (&pdev->dev,"Could not register input device.\n" ); +return ret; + } + + ret = devm_request_threaded_irq(&pdev->dev, sensehat->i2c_client->irq, + NULL, sensehat_joystick_report, + IRQF_TRIGGER_RISING | IRQF_ONESHOT,
Do not specify trigger type, whoever set up client's interrupt should have set up appropriate trigger.
Quoted 5 lines
drivers/input/joystick/sensehat-joystick.c new file +5
-0+ "keys", sensehat); + +if (ret) { +dev_err (&pdev->dev,"IRQ request failed.\n" ); +return ret;
drivers/input/joystick/sensehat-joystick.c line 99
Quoted 10 lines
drivers/input/joystick/sensehat-joystick.c new file +10
-0+ } +return 0 ; +} + +int sensehat_get_joystick_state (struct sensehat *sensehat) +{ +unsigned int reg; +int ret =regmap_read (sensehat->regmap,SENSEHAT_KEYS , ®); + +return ret <0 ? ret : reg;
I do not see the point in having this wrapper.
Quoted 23 lines
drivers/input/joystick/sensehat-joystick.c new file +20
-0+} + +static struct platform_device_id sensehat_joystick_device_id[] = { + { .name ="sensehat-joystick" }, + {}, +}; +MODULE_DEVICE_TABLE (platform, sensehat_joystick_device_id); + +static struct platform_driver sensehat_joystick_driver = { + .probe = sensehat_joystick_probe, + .driver = { + .name ="sensehat-joystick" , + }, +}; + +module_platform_driver (sensehat_joystick_driver); + +MODULE_DESCRIPTION ("Raspberry Pi Sense HAT joystick driver" ); +MODULE_AUTHOR ("Serge Schneider <[email protected]>" ); +MODULE_LICENSE ("GPL" );Signature · 1 line
2.31.1
Thanks.
Signature · 1 line
Dmitry
PATCH v5 3/6 drivers/auxdisplay: sensehat: Raspberry Pi Sense HAT display driver
In reply to Charles MirabileThis patch implements control of the 8x8 RGB LED matrix display.
--- drivers/auxdisplay/Kconfig | 8 + drivers/auxdisplay/Makefile | 1 + drivers/auxdisplay/sensehat-display.c | 268 ++++++++++++++++++++++++++ 3 files changed, 277 insertions(+) create mode 100644 drivers/auxdisplay/sensehat-display.c
drivers/auxdisplay/Kconfig +8 -0
@@ -203,6 +203,14 @@ 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" + depends on I2C + 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
@@ -14,3 +14,4 @@ obj-$(CONFIG_HT16K33) += ht16k33.o obj-$(CONFIG_PARPORT_PANEL) += panel.o obj-$(CONFIG_LCD2S) += lcd2s.o obj-$(CONFIG_LINEDISP) += line-display.o +obj-$(CONFIG_SENSEHAT_DISPLAY) += sensehat-display.o
drivers/auxdisplay/sensehat-display.c new file +268 -0
268 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH V5 3/6] drivers/auxdisplay: sensehat: Raspberry Pi Sense HAT display driver
Hi Charles, Mwesigwa, Joel, Serge,
Quoted 6 lines · Charles Mirabile
Signed-off-by Charles Mirabile <[email protected]>Co-developed-by Mwesigwa Guma <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Co-developed-by Joel Savitz <[email protected]>Signed-off-by Joel Savitz <[email protected]>
The "submitting author" should be the last one, i.e.:
drivers/auxdisplay/Kconfig config ARM_CHARLCD · line 207
Quoted 2 lines
drivers/auxdisplay/Kconfig +2
-0+config SENSEHAT_DISPLAY + tristate "Raspberry pi Sense HAT display driver"
pi -> Pi
Quoted 1 line
+static int
sensehat_update_display(struct sensehat *sensehat);
Can the function be directly defined instead?
drivers/auxdisplay/sensehat-display.c line 134
Quoted 4 lines
drivers/auxdisplay/sensehat-display.c new file +4
-0+if (*f_pos >=VMEM_SIZE ) +return 0 ; +if (*f_pos + count >VMEM_SIZE ) + count =VMEM_SIZE - *f_pos;
min / min_t?
drivers/auxdisplay/sensehat-display.c line 238
Quoted 3 lines
drivers/auxdisplay/sensehat-display.c new file +3
-0+if (ret <0 ) +dev_err (sensehat->dev, +"Update to 8x8 LED matrix display failed" );
Could this happen a lot of times? Is it expected to happen under some condition or should never happen?
Cheers,
Miguel
PATCH v5 4/6 dt-bindings: mfd: sensehat: Add Raspberry Pi Sense HAT schema
In reply to Charles MirabileThis patch adds the device tree binding
for the Sense HAT in yaml form.
--- .../bindings/mfd/raspberrypi,sensehat.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml
Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml new file +54 -0
@@ -0,0 +1,54 @@ +# 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: + const: raspberrypi,sensehat + + reg: + items: + - description: i2c bus address + + interrupts: + items: + - description: pin number for joystick interrupt + + interrupt-parent: + items: + - description: gpio pin bank for interrupt pin + +required: + - compatible + - reg + - interrupts + - interrupt-parent + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + sensehat@46 { + compatible = "raspberrypi,sensehat"; + reg = <0x46>; + interrupts = <23 GPIO_ACTIVE_HIGH>; + interrupt-parent = <&gpio>; + }; + };
Signature · 1 line
2.31.1
Rob Herring
maintainerRe: [PATCH V5 4/6] dt-bindings: mfd: sensehat: Add Raspberry Pi Sense HAT schema
Quoted 8 lines · Charles Mirabile
This patch adds the device tree binding
for the Sense HAT in yaml form.Signed-off-by Charles Mirabile <[email protected]>Co-developed-by Mwesigwa Guma <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Co-developed-by Joel Savitz <[email protected]>Signed-off-by Joel Savitz <[email protected]>
Quoted 5 lines
--- .../bindings/mfd/raspberrypi,sensehat.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:./Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml:2:1: [error] missing document start "---" (document-start)
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml: properties:interrupt-parent: False schema does not allow {'items': [{'description': 'gpio pin bank for interrupt pin'}]}
from schema $id: http://devicetree.org/meta-schemas/interrupts.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml: ignoring, error in schema: properties: interrupt-parent
warning: no schema found in file: ./Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yamlDocumentation/devicetree/bindings/mfd/raspberrypi,sensehat.example.dt.yaml:0:0: /example-0/i2c/sensehat@46: failed to match any schema with compatible: ['raspberrypi,sensehat']
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1566669
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Rob Herring
maintainerRe: [PATCH V5 4/6] dt-bindings: mfd: sensehat: Add Raspberry Pi Sense HAT schema
Quoted 21 lines · Rob Herring
Quoted 8 lines · Charles Mirabile
This patch adds the device tree binding
for the Sense HAT in yaml form.Signed-off-by Charles Mirabile <[email protected]>Co-developed-by Mwesigwa Guma <[email protected]>Signed-off-by Mwesigwa Guma <[email protected]>Co-developed-by Joel Savitz <[email protected]>Signed-off-by Joel Savitz <[email protected]>Quoted 5 lines
--- .../bindings/mfd/raspberrypi,sensehat.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yamlMy bot found errors running 'make DT_CHECKER_FLAGS=-m
dt_binding_check' on your patch (DT_CHECKER_FLAGSis new in v5.13):yamllint warnings/errors:
./Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml:2:1: [error] missing document start "---" (document-start)
Quoted 6 lines
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml: properties:interrupt-parent: False schema does not allow {'items': [{'description': 'gpio pin bank for interrupt pin'}]}
from schema $id: http://devicetree.org/meta-schemas/interrupts.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yaml: ignoring, error in schema: properties: interrupt-parent
warning: no schema found in file:./Documentation/devicetree/bindings/mfd/raspberrypi,sensehat.yamlDocumentation/devicetree/bindings/mfd/raspberrypi,sensehat.example.dt.yaml:0:0: /example-0/i2c/sensehat@46: failed to match any schema with compatible: ['raspberrypi,sensehat']
'interrupt-parent' is not needed as it is always valid or could be in a parent node.
PATCH v5 5/6 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
@@ -17167,6 +17167,17 @@ F: Documentation/ABI/testing/sysfs-bus-iio-chemical-sunrise-co2 F: Documentation/devicetree/bindings/iio/chemical/senseair,sunrise.yaml F: drivers/iio/chemical/sunrise_co2.c +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
PATCH v5 6/6 DO NOT MERGE: full sensehat device tree overlay for raspberry pi 4
In reply to Charles MirabileThis patch shold not be merged - dtbs files are not stored in the kernel tree. We just provide this file so the code can be tested.
This overlay is suitable for testing the driver, it can be compiled with dtc and put in the /boot/overlays/ folder then specified in config.txt by putting the lines:
dtoverlay= #suppress loading of default overlay for HAT
dtoverlay=sensehat #load custom overlay
at the beginning before any other lines in config.txt
--- sensehat.dtbs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sensehat.dtbs
sensehat.dtbs new file +44 -0
@@ -0,0 +1,44 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "brcm,bcm2835"; +}; + +&i2c1 { + #address-cells = <0x01>; + #size-cells = <0x00>; + status = "okay"; + + sensehat@46 { + compatible = "raspberrypi,sensehat"; + reg = <0x46>; + interrupts = <23 1>; + interrupt-parent = <&gpio>; + status = "okay"; + }; + + lsm9ds1-magn@1c { + compatible = "st,lsm9ds1-magn"; + reg = <0x1c>; + status = "okay"; + }; + + lsm9ds1-accel@6a { + compatible = "st,lsm9ds1-accel"; + reg = <0x6a>; + status = "okay"; + }; + + lps25h-press@5c { + compatible = "st,lps25h-press"; + reg = <0x5c>; + status = "okay"; + }; + + hts221-humid@5f { + compatible = "st,hts221-humid\0st,hts221"; + reg = <0x5f>; + status = "okay"; + }; +};
Signature · 1 line
2.31.1
Hi Charles, Thanks for iterating on this.
Quoted 4 lines · Charles Mirabile
Suggestions from v4 not addressed yet:
- Usemfd_cellsfor the joystick and display platform devices (as suggested by Matthias Brugger) or removesensehat-core.centirely and use simple-mfd-i2c instead (as suggested by
Quoted 8 lines
Nicolás Sáenz Julienne).
- while these suggestions might make great improvements for a version two of the driver they would require a large rewrite to move all of the complexity in core elsewhere. While certainly possible and something we want to iterate on and achieve eventually, we think saving it for down the road makes sense at this time.
Sorry for insisting, but I'm not convinced by this approach. The way you design your driver affects its devicetree bindings, once we settle on those any upgrade will have to be backwards compatible (i.e. an old DT would have to work with the new implementation). This makes changing this further down the road unlikely.
In terms of complexity, most of it is there due to not using the APIs and facilities the mfd subsystem provides. See my comments in the driver.
Regards,
Signature · 1 line
Nicolás Sáenz