riscv:dts:add mango-reset and gpio-key

This commit is contained in:
chunzhi.lin 2023-03-20 19:27:20 +08:00 committed by Xiaoguang Xing
parent f4a91a3d23
commit c0151c9924
6 changed files with 100 additions and 9 deletions

View File

@ -13,6 +13,11 @@
reg = <0x17>;
#thermal-sensor-cells = <1>;
};
mango_srst: mango-reset@17 {
compatible = "mango,reset";
reg = <0x17>;
};
};
&i2c2 {
@ -20,6 +25,38 @@
pinctrl-0 = <&i2c2_acquire>;
};
&soc {
gpio-poweroff {
compatible = "gpio-keys";
input-name = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pwr_key>;
power {
label = "GPIO Key Power";
linux,code = <KEY_POWER>;
gpios = <&port0a 22 GPIO_ACTIVE_HIGH>;
linux,input-type = <1>;
debounce-interval = <100>;
};
};
gpio-restart {
compatible = "gpio-keys";
input-name = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&restart_key>;
restart {
label = "GPIO Key Restart";
linux,code = <KEY_RESTART>;
gpios = <&port0a 23 GPIO_ACTIVE_HIGH>;
linux,input-type = <1>;
debounce-interval = <100>;
};
};
};
&tach0 {
pinctrl-names = "default";
pinctrl-0 = <&fan0_acquire>;

View File

@ -382,6 +382,20 @@
};
};
pwr_key: pwr-key {
mux {
pins = <147>;
function = "gpio0_a";
};
};
restart_key: restart-key {
mux {
pins = <148>;
function = "gpio0_a";
};
};
dbgi2c_acquire: dbgi2c_acquire {
mux {
groups = "dbgi2c_grp";

View File

@ -13,6 +13,11 @@
reg = <0x17>;
#thermal-sensor-cells = <1>;
};
mango_srst: mango-reset@17 {
compatible = "mango,reset";
reg = <0x17>;
};
};
&i2c2 {
@ -20,6 +25,38 @@
pinctrl-0 = <&i2c2_acquire>;
};
&soc {
gpio-poweroff {
compatible = "gpio-keys";
input-name = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pwr_key>;
power {
label = "GPIO Key Power";
linux,code = <KEY_POWER>;
gpios = <&port0a 22 GPIO_ACTIVE_HIGH>;
linux,input-type = <1>;
debounce-interval = <100>;
};
};
gpio-restart {
compatible = "gpio-keys";
input-name = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&restart_key>;
restart {
label = "GPIO Key Restart";
linux,code = <KEY_RESTART>;
gpios = <&port0a 23 GPIO_ACTIVE_HIGH>;
linux,input-type = <1>;
debounce-interval = <100>;
};
};
};
&tach0 {
pinctrl-names = "default";
pinctrl-0 = <&fan0_acquire>;

View File

@ -1,6 +1,8 @@
/dts-v1/;
#include <dt-bindings/clock/sophgo.h>
#include <dt-bindings/clock/sophgo-mango-clock.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/reset/sophgo-mango-resets.h>
#include <dt-bindings/interrupt-controller/irq.h>
@ -59,7 +61,7 @@
numa-node-id = <3>;
};
soc {
soc: soc {
#address-cells = <2>;
#size-cells = <2>;
compatible = "simple-bus";

View File

@ -217,7 +217,9 @@ static const unsigned int spi1_pins[] = {102, 103, 104, 105, 106};
static const unsigned int jtag0_pins[] = {107, 108, 109, 110, 111, 112};
static const unsigned int jtag1_pins[] = {113, 114, 115, 116, 117, 118};
static const unsigned int jtag2_pins[] = {119, 120, 121, 122, 123, 124};
// GPIO0 is pin 125
static const unsigned int gpio0_pins[] = {125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,\
138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,\
151, 152, 153};
static const unsigned int dbgi2c_pins[] = {154, 155, 156};
static const char * const lpc_group[] = {"lpc_grp"};
@ -247,6 +249,7 @@ static const char * const spi1_group[] = {"spi1_grp"};
static const char * const jtag0_group[] = {"jtag0_grp"};
static const char * const jtag1_group[] = {"jtag1_grp"};
static const char * const jtag2_group[] = {"jtag2_grp"};
static const char * const gpio0_group[] = {"gpio0_grp"};
static const char * const dbgi2c_group[] = {"dbgi2c_grp"};
static struct mango_group mango_groups[] = {
@ -277,6 +280,7 @@ static struct mango_group mango_groups[] = {
PIN_GROUP(jtag0),
PIN_GROUP(jtag1),
PIN_GROUP(jtag2),
PIN_GROUP(gpio0),
PIN_GROUP(dbgi2c),
};
@ -335,6 +339,8 @@ static const struct mango_pmx_func mango_funcs[] = {
FUNCTION(jtag1_r, jtag1, FUNC_MODE0),
FUNCTION(jtag2_a, jtag2, FUNC_MODE1),
FUNCTION(jtag2_r, jtag2, FUNC_MODE0),
FUNCTION(gpio0_a, gpio0, FUNC_MODE1),
FUNCTION(gpio0_r, gpio0, FUNC_MODE0),
FUNCTION(dbgi2c_a, dbgi2c, FUNC_MODE0),
FUNCTION(dbgi2c_r, dbgi2c, FUNC_MODE1),
};
@ -366,6 +372,7 @@ static struct device_attribute spi1_attr = __ATTR(spi1, 0664, pinmux_show, pinmu
static struct device_attribute jtag0_attr = __ATTR(jtag0, 0664, pinmux_show, pinmux_store);
static struct device_attribute jtag1_attr = __ATTR(jtag1, 0664, pinmux_show, pinmux_store);
static struct device_attribute jtag2_attr = __ATTR(jtag2, 0664, pinmux_show, pinmux_store);
static struct device_attribute gpio0_attr = __ATTR(gpio0, 0664, pinmux_show, pinmux_store);
static struct device_attribute dbgi2c_attr = __ATTR(dbgi2c, 0664, pinmux_show, pinmux_store);
@ -397,6 +404,7 @@ static struct attribute *pinmux_attrs[] = {
&jtag0_attr.attr,
&jtag1_attr.attr,
&jtag2_attr.attr,
&gpio0_attr.attr,
&dbgi2c_attr.attr,
NULL,
};

View File

@ -364,7 +364,6 @@ ssize_t info_show(struct device *dev, struct device_attribute *attr,
struct mcu_info *info = &ctx->info;
const struct mcu_features *features = ctx->features;
int err;
struct nvmem_cell *cell;
if (info->updated == 0) {
/* get information from mcu through i2c */
@ -378,12 +377,6 @@ ssize_t info_show(struct device *dev, struct device_attribute *attr,
info->updated = 1;
}
cell = devm_nvmem_cell_get(dev, "sn");
if (IS_ERR(cell)) {
dev_err(dev, "failed to get cell\n");
return PTR_ERR(cell);
}
/* convert to json text */
mcu_msg_append(buf, PAGE_SIZE, "{\n");
mcu_msg_append(buf, PAGE_SIZE, "\t\"model\": \"%s\",\n", features->proj);