Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert switch to upstream HAT patches #6393

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions arch/arm/boot/dts/overlays/hat_map.dts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,4 @@
uuid = [ 1c955808 681f 4bbc a2ef b7ea47cd388e ];
overlay = "recalboxrgbdual";
};

sensehat-v1 {
uuid = [ 5d960035 8e87 428f 95d8 59852d697754 ];
overlay = "rpi-sense";
};

sensehat-v2 {
uuid = [ 1aa9c428 72eb 48da 9306 8c3706ed3653 ];
overlay = "rpi-sense-v2";
};
};
28 changes: 3 additions & 25 deletions arch/arm/boot/dts/overlays/rpi-sense-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,11 @@
#size-cells = <0>;
status = "okay";

sensehat@46 {
compatible = "raspberrypi,sensehat";
rpi-sense@46 {
compatible = "rpi,rpi-sense";
reg = <0x46>;
interrupt-parent = <&gpio>;
keys-int-gpios = <&gpio 23 1>;
status = "okay";

display {
compatible = "raspberrypi,rpi-sense-fb";
status = "okay";
};
joystick {
compatible = "raspberrypi,sensehat-joystick";
interrupts = <23 1>;
pinctrl-names = "default";
pinctrl-0 = <&sensehat_pins>;
status = "okay";
};
};

lsm9ds1-magn@1c {
Expand Down Expand Up @@ -56,14 +44,4 @@
};
};
};

fragment@1 {
target = <&gpio>;
__overlay__ {
sensehat_pins: sensehat_pins {
brcm,pins = <23>;
brcm,function = <0>;
};
};
};
};
28 changes: 3 additions & 25 deletions arch/arm/boot/dts/overlays/rpi-sense-v2-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,11 @@
#size-cells = <0>;
status = "okay";

sensehat@46 {
compatible = "raspberrypi,sensehat";
rpi-sense@46 {
compatible = "rpi,rpi-sense";
reg = <0x46>;
interrupt-parent = <&gpio>;
keys-int-gpios = <&gpio 23 1>;
status = "okay";

display {
compatible = "raspberrypi,rpi-sense-fb";
status = "okay";
};
joystick {
compatible = "raspberrypi,sensehat-joystick";
interrupts = <23 1>;
pinctrl-names = "default";
pinctrl-0 = <&sensehat_pins>;
status = "okay";
};
};

lsm9ds1-magn@1c {
Expand Down Expand Up @@ -56,14 +44,4 @@
};
};
};

fragment@1 {
target = <&gpio>;
__overlay__ {
sensehat_pins: sensehat_pins {
brcm,pins = <23>;
brcm,function = <0>;
};
};
};
};
2 changes: 1 addition & 1 deletion arch/arm/configs/bcm2709_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ CONFIG_JOYSTICK_XPAD_LEDS=y
CONFIG_JOYSTICK_PSXPAD_SPI=m
CONFIG_JOYSTICK_PSXPAD_SPI_FF=y
CONFIG_JOYSTICK_FSIA6B=m
CONFIG_JOYSTICK_SENSEHAT=m
CONFIG_JOYSTICK_RPISENSE=m
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_ADS7846=m
CONFIG_TOUCHSCREEN_EGALAX=m
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/configs/bcm2711_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ CONFIG_JOYSTICK_XPAD_LEDS=y
CONFIG_JOYSTICK_PSXPAD_SPI=m
CONFIG_JOYSTICK_PSXPAD_SPI_FF=y
CONFIG_JOYSTICK_FSIA6B=m
CONFIG_JOYSTICK_SENSEHAT=m
CONFIG_JOYSTICK_RPISENSE=m
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_ADS7846=m
CONFIG_TOUCHSCREEN_EGALAX=m
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/configs/bcmrpi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ CONFIG_JOYSTICK_XPAD_LEDS=y
CONFIG_JOYSTICK_PSXPAD_SPI=m
CONFIG_JOYSTICK_PSXPAD_SPI_FF=y
CONFIG_JOYSTICK_FSIA6B=m
CONFIG_JOYSTICK_SENSEHAT=m
CONFIG_JOYSTICK_RPISENSE=m
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_ADS7846=m
CONFIG_TOUCHSCREEN_EGALAX=m
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/configs/bcm2711_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ CONFIG_JOYSTICK_XPAD_LEDS=y
CONFIG_JOYSTICK_PSXPAD_SPI=m
CONFIG_JOYSTICK_PSXPAD_SPI_FF=y
CONFIG_JOYSTICK_FSIA6B=m
CONFIG_JOYSTICK_SENSEHAT=m
CONFIG_JOYSTICK_RPISENSE=m
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_ADS7846=m
CONFIG_TOUCHSCREEN_EGALAX=m
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/configs/bcm2712_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ CONFIG_JOYSTICK_XPAD_LEDS=y
CONFIG_JOYSTICK_PSXPAD_SPI=m
CONFIG_JOYSTICK_PSXPAD_SPI_FF=y
CONFIG_JOYSTICK_FSIA6B=m
CONFIG_JOYSTICK_SENSEHAT=m
CONFIG_JOYSTICK_RPISENSE=m
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_ADS7846=m
CONFIG_TOUCHSCREEN_EGALAX=m
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/configs/bcmrpi3_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ CONFIG_JOYSTICK_XPAD_LEDS=y
CONFIG_JOYSTICK_PSXPAD_SPI=m
CONFIG_JOYSTICK_PSXPAD_SPI_FF=y
CONFIG_JOYSTICK_FSIA6B=m
CONFIG_JOYSTICK_SENSEHAT=m
CONFIG_JOYSTICK_RPISENSE=m
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_ADS7846=m
CONFIG_TOUCHSCREEN_EGALAX=m
Expand Down
8 changes: 8 additions & 0 deletions drivers/input/joystick/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,12 @@
To compile this driver as a module, choose M here: the
module will be called sensehat_joystick.

config JOYSTICK_RPISENSE

Check failure on line 415 in drivers/input/joystick/Kconfig

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: please write a help paragraph that fully describes the config symbol
tristate "Raspberry Pi Sense HAT joystick"
depends on GPIOLIB && INPUT
select MFD_RPISENSE_CORE

help
This is the joystick driver for the Raspberry Pi Sense HAT

endif
1 change: 1 addition & 0 deletions drivers/input/joystick/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o
obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o
obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o
obj-$(CONFIG_JOYSTICK_RPISENSE) += rpisense-js.o
153 changes: 153 additions & 0 deletions drivers/input/joystick/rpisense-js.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Raspberry Pi Sense HAT joystick driver
* http://raspberrypi.org
*
* Copyright (C) 2015 Raspberry Pi
*
* Author: Serge Schneider
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/

#include <linux/module.h>

#include <linux/mfd/rpisense/joystick.h>
#include <linux/mfd/rpisense/core.h>

static struct rpisense *rpisense;
static unsigned char keymap[5] = {KEY_DOWN, KEY_RIGHT, KEY_UP, KEY_ENTER, KEY_LEFT,};

static void keys_work_fn(struct work_struct *work)
{
int i;
static s32 prev_keys;
struct rpisense_js *rpisense_js = &rpisense->joystick;
s32 keys = rpisense_reg_read(rpisense, RPISENSE_KEYS);
s32 changes = keys ^ prev_keys;

prev_keys = keys;
for (i = 0; i < 5; i++) {
if (changes & 1) {
input_report_key(rpisense_js->keys_dev,
keymap[i], keys & 1);
}
changes >>= 1;
keys >>= 1;
}
input_sync(rpisense_js->keys_dev);
}

static irqreturn_t keys_irq_handler(int irq, void *pdev)
{
struct rpisense_js *rpisense_js = &rpisense->joystick;

schedule_work(&rpisense_js->keys_work_s);
return IRQ_HANDLED;
}

static int rpisense_js_probe(struct platform_device *pdev)
{
int ret;
int i;
struct rpisense_js *rpisense_js;

rpisense = rpisense_get_dev();
rpisense_js = &rpisense->joystick;

INIT_WORK(&rpisense_js->keys_work_s, keys_work_fn);

rpisense_js->keys_dev = input_allocate_device();
if (!rpisense_js->keys_dev) {
dev_err(&pdev->dev, "Could not allocate input device.\n");
return -ENOMEM;
}

rpisense_js->keys_dev->evbit[0] = BIT_MASK(EV_KEY);
for (i = 0; i < ARRAY_SIZE(keymap); i++) {
set_bit(keymap[i],
rpisense_js->keys_dev->keybit);
}

rpisense_js->keys_dev->name = "Raspberry Pi Sense HAT Joystick";
rpisense_js->keys_dev->phys = "rpi-sense-joy/input0";
rpisense_js->keys_dev->id.bustype = BUS_I2C;
rpisense_js->keys_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
rpisense_js->keys_dev->keycode = keymap;
rpisense_js->keys_dev->keycodesize = sizeof(unsigned char);
rpisense_js->keys_dev->keycodemax = ARRAY_SIZE(keymap);

ret = input_register_device(rpisense_js->keys_dev);
if (ret) {
dev_err(&pdev->dev, "Could not register input device.\n");
goto err_keys_alloc;
}

ret = gpiod_direction_input(rpisense_js->keys_desc);
if (ret) {
dev_err(&pdev->dev, "Could not set keys-int direction.\n");
goto err_keys_reg;
}

rpisense_js->keys_irq = gpiod_to_irq(rpisense_js->keys_desc);
if (rpisense_js->keys_irq < 0) {
dev_err(&pdev->dev, "Could not determine keys-int IRQ.\n");
ret = rpisense_js->keys_irq;
goto err_keys_reg;
}

ret = devm_request_irq(&pdev->dev, rpisense_js->keys_irq,
keys_irq_handler, IRQF_TRIGGER_RISING,
"keys", &pdev->dev);
if (ret) {
dev_err(&pdev->dev, "IRQ request failed.\n");
goto err_keys_reg;
}
return 0;
err_keys_reg:
input_unregister_device(rpisense_js->keys_dev);
err_keys_alloc:
input_free_device(rpisense_js->keys_dev);
return ret;
}

static int rpisense_js_remove(struct platform_device *pdev)
{
struct rpisense_js *rpisense_js = &rpisense->joystick;

input_unregister_device(rpisense_js->keys_dev);
input_free_device(rpisense_js->keys_dev);
return 0;
}

#ifdef CONFIG_OF
static const struct of_device_id rpisense_js_id[] = {
{ .compatible = "rpi,rpi-sense-js" },
{ },
};
MODULE_DEVICE_TABLE(of, rpisense_js_id);
#endif

static struct platform_device_id rpisense_js_device_id[] = {
{ .name = "rpi-sense-js" },
{ },
};
MODULE_DEVICE_TABLE(platform, rpisense_js_device_id);

static struct platform_driver rpisense_js_driver = {
.probe = rpisense_js_probe,
.remove = rpisense_js_remove,
.driver = {
.name = "rpi-sense-js",
.owner = THIS_MODULE,
},
};

module_platform_driver(rpisense_js_driver);

MODULE_DESCRIPTION("Raspberry Pi Sense HAT joystick driver");
MODULE_AUTHOR("Serge Schneider <[email protected]>");
MODULE_LICENSE("GPL");
2 changes: 1 addition & 1 deletion drivers/input/joystick/sensehat-joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct sensehat_joystick {
};

static const unsigned int keymap[] = {
KEY_DOWN, KEY_RIGHT, KEY_UP, KEY_ENTER, KEY_LEFT
BTN_DPAD_DOWN, BTN_DPAD_RIGHT, BTN_DPAD_UP, BTN_SELECT, BTN_DPAD_LEFT,
};

static irqreturn_t sensehat_joystick_report(int irq, void *cookie)
Expand Down
8 changes: 8 additions & 0 deletions drivers/mfd/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
select IRQ_DOMAIN
default n

config MFD_RPISENSE_CORE

Check failure on line 14 in drivers/mfd/Kconfig

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: please write a help paragraph that fully describes the config symbol
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
Expand Down
1 change: 1 addition & 0 deletions drivers/mfd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ obj-$(CONFIG_MFD_STMFX) += stmfx.o
obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o
obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o
obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o
obj-$(CONFIG_MFD_RPISENSE_CORE) += rpisense-core.o

obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o
Expand Down
Loading
Loading