内核目录下 /sys/class/gpio 下实现
.../arm64/configs/aeon6737t_66_d_n_debug_defconfig | 1 +
arch/arm64/configs/aeon6737t_66_d_n_defconfig | 1 +
drivers/gpio/gpiolib-sysfs.c | 105 +++++++++++++++++++++
drivers/misc/mediatek/aeondws/codegen_F515.dws | Bin 30503 -> 30060 bytes
drivers/misc/mediatek/gpio/aeon_gpio.c | 65 ++++++++++++-
include/asm-generic/gpio.h | 9 +-
include/linux/gpio.h | 8 ++
tools/dct/old_dct/Keypad_YuSu.cmp | 2 +-
8 files changed, 188 insertions(+), 3 deletions(-)
mode change 100755 => 100644 drivers/misc/mediatek/aeondws/codegen_F515.dws
diff --git a/arch/arm64/configs/aeon6737t_66_d_n_debug_defconfig b/arch/arm64/configs/aeon6737t_66_d_n_debug_defconfig
index ae29cfb..aeba932 100755
--- a/arch/arm64/configs/aeon6737t_66_d_n_debug_defconfig
+++ b/arch/arm64/configs/aeon6737t_66_d_n_debug_defconfig
@@ -328,6 +328,7 @@ CONFIG_INPUT_UINPUT=y
CONFIG_LEGACY_PTY_COUNT=16
# CONFIG_HW_RANDOM is not set
CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
CONFIG_SPI=y
CONFIG_MTK_SPI=y
CONFIG_MTK_SMART_BATTERY=y
diff --git a/arch/arm64/configs/aeon6737t_66_d_n_defconfig b/arch/arm64/configs/aeon6737t_66_d_n_defconfig
index 182fefc..e515d9f 100755
--- a/arch/arm64/configs/aeon6737t_66_d_n_defconfig
+++ b/arch/arm64/configs/aeon6737t_66_d_n_defconfig
@@ -318,6 +318,7 @@ CONFIG_LEGACY_PTY_COUNT=16
# CONFIG_DEVKMEM is not set
# CONFIG_HW_RANDOM is not set
CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
CONFIG_SPI=y
CONFIG_MTK_SPI=y
CONFIG_MTK_SMART_BATTERY=y
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index d9fa798..3d53960 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -604,6 +604,111 @@ fail_unlock:
}
EXPORT_SYMBOL_GPL(gpiod_export);
+/**
+ * gpiod_export_with_name - export a GPIO through sysfs
+ * @gpio: gpio to make available, already requested
+ * @direction_may_change: true if userspace may change gpio direction
+ * @name: gpio name
+ * Context: arch_initcall or later
+ *
+ * When drivers want to make a GPIO accessible to userspace after they
+ * have requested it -- perhaps while debugging, or as part of their
+ * public interface -- they may use this routine. If the GPIO can
+ * change direction (some can't) and the caller allows it, userspace
+ * will see "direction" sysfs attribute which may be used to change
+ * the gpio's direction. A "value" attribute will always be provided.
+ *
+ * Returns zero on success, else an error.
+ */
+int gpiod_export_with_name(struct gpio_desc *desc, bool direction_may_change,
+ const char *name)
+{
+ struct gpio_chip *chip;
+ unsigned long flags;
+ int status;
+ const char *ioname = NULL;
+ struct device *dev;
+ int offset;
+
+ /* can't export until sysfs is available ... */
+ if (!gpio_class.p) {
+ pr_debug("%s: called too early!\n", __func__);
+ return -ENOENT;
+ }
+
+ if (!desc) {
+ pr_debug("%s: invalid gpio descriptor\n", __func__);
+ return -EINVAL;
+ }
+
+ chip = desc->chip;
+
+ mutex_lock(&sysfs_lock);
+
+ /* check if chip is being removed */
+ if (!chip || !chip->exported) {
+ status = -ENODEV;
+ goto fail_unlock;
+ }
+
+ spin_lock_irqsave(&gpio_lock, flags);
+ if (!test_bit(FLAG_REQUESTED, &desc->flags) ||
+ test_bit(FLAG_EXPORT, &desc->flags)) {
+ spin_unlock_irqrestore(&gpio_lock, flags);
+ gpiod_dbg(desc, "%s: unavailable (requested=%d, exported=%d)\n",
+ __func__,
+ test_bit(FLAG_REQUESTED, &desc->flags),
+ test_bit(FLAG_EXPORT, &desc->flags));
+ status = -EPERM;
+ goto fail_unlock;
+ }
+
+ if (!desc->chip->direction_input || !desc->chip->direction_output)
+ direction_may_change = false;
+ spin_unlock_irqrestore(&gpio_lock, flags);
+
+ offset = gpio_chip_hwgpio(desc);
+ //if (desc->chip->names && desc->chip->names[offset])
+ // ioname = desc->chip->names[offset];
+ ioname = name;
+
+ dev = device_create_with_groups(&gpio_class, desc->chip->dev,
+ MKDEV(0, 0), desc, gpio_groups,
+ ioname ? ioname : "gpio%u",
+ desc_to_gpio(desc));
+ if (IS_ERR(dev)) {
+ status = PTR_ERR(dev);
+ goto fail_unlock;
+ }
+
+ if (direction_may_change) {
+ status = device_create_file(dev, &dev_attr_direction);
+ if (status)
+ goto fail_unregister_device;
+ }
+
+ if (gpiod_to_irq(desc) >= 0 && (direction_may_change ||
+ !test_bit(FLAG_IS_OUT, &desc->flags))) {
+ status = device_create_file(dev, &dev_attr_edge);
+ if (status)
+ goto fail_remove_attr_direction;
+ }
+
+ set_bit(FLAG_EXPORT, &desc->flags);
+ mutex_unlock(&sysfs_lock);
+ return 0;
+
+fail_remove_attr_direction:
+ device_remove_file(dev, &dev_attr_direction);
+fail_unregister_device:
+ device_unregister(dev);
+fail_unlock:
+ mutex_unlock(&sysfs_lock);
+ gpiod_dbg(desc, "%s: status %d\n", __func__, status);
+ return status;
+}
+EXPORT_SYMBOL_GPL(gpiod_export_with_name);
+
static int match_export(struct device *dev, const void *data)
{
return dev_get_drvdata(dev) == data;
diff --git a/drivers/misc/mediatek/aeondws/codegen_F515.dws b/drivers/misc/mediatek/aeondws/codegen_F515.dws
old mode 100755
new mode 100644
index 098b37bc7435588e385ec4a2d6327ac009e0d587..1dc4dff9c9d0352af33350c2b554529f3402783f
GIT binary patch
delta 2634
zcmb_eUu;ul6z}bB+uLy+ck5l-&DP#+g@G-ue?|w&x?9=}M%T3)9Sk$<2u32{K(`WN
zh}o-&M8+@1gdmANsPRE-t|l5VEXMd`OnDdNK_C2w3r~i`;Q8)t#~m397@B<TJ>NOs
z`SbgJ=iGjDi~I9;&YR1O@8c{Mi%iQwD_2bP#kX31z@gSIEZPN}*l0t}?SjM$sCv9u
za!ld`7hF*Jn#zmaT$YJ1cZ!%-1t@}un?p`4a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2K0b;31tDP2{M5)!MhO~FoPXqE$`jXn;iI_%b;kyg-G+CB#zJ>XK
za(59-TcchV|E~XWzG#P4iKvj3Y$aH~_{J%!--g3!u~;c(Dw4_Ge9<WL;PQv{yO%zr
z;O?bLJ^R)t)NmWxf#@?5ukuCpOlCH|-P?I3yR-wZiwberhBpx`*&doy%%#nhbcM{5
zOt+Z`j+jWs+d~d$DK`9evBUb6X|05UC}ip<=fAg@6LI+Gos$r{ez=?XVvht_EUTFr
z1uiW59I>p4Oy>)w^bAxM51JEcC@mhhYbDq95~ppW<68b%g@E>trc4c5<;bfmp49#T
z$+JRQQVMwakwEb%+*lmZh=DzqWU`z&k%GbNN8q(<!(F5`x<1O4DM(-QQRDDz@o*QW
zr2VsPWJ(P7SjN;O28QWQPBpU8Ie{2IHAW&Y5znc!@kIQUq>1dI5a(1bpB98nQ61HS
zL~o+E0gH{L_J*akMa1(lE*2f*_Qb`aCXIgN8-}l6hRD0#WAZtb69uI#7PS`c{rW$#
CNM=z0
diff --git a/drivers/misc/mediatek/gpio/aeon_gpio.c b/drivers/misc/mediatek/gpio/aeon_gpio.c
index 9935203..756bd9f 100755
--- a/drivers/misc/mediatek/gpio/aeon_gpio.c
+++ b/drivers/misc/mediatek/gpio/aeon_gpio.c
@@ -148,6 +148,66 @@ unsigned int aeon_get_pwm_num(const char *name)
}
EXPORT_SYMBOL_GPL(aeon_get_pwm_num);
+#define CHG_CTL 9
+#define CHG_EN 3
+#define CHG_STAT 1
+#define METER_CTL 0
+#define METER_RESERV 11
+#define NLS_RST 7
+#define NLS_TRIG 8
+#define PINGOPIN_EN 5
+//#define PWR_PA
+#define PWR_PINGOPIN 83
+#define PWR_UART 6
+#define UART_EN 4
+
+void custom_gpio_init(void)
+{
+ gpio_request(CHG_CTL, "chg_ctl");
+ mt_set_gpio_dir(CHG_CTL, 1);
+ gpio_export_with_name(CHG_CTL, true, "chg_ctl");
+
+ gpio_request(CHG_EN, "chg_en");
+ mt_set_gpio_dir(CHG_EN, 1);
+ gpio_export_with_name(CHG_EN, true, "chg_en");
+
+ gpio_request(CHG_STAT, "chg_stat");
+ mt_set_gpio_dir(CHG_STAT, 1);
+ gpio_export_with_name(CHG_STAT, true, "chg_stat");
+
+ gpio_request(METER_CTL, "meter_ctl");
+ mt_set_gpio_dir(METER_CTL, 1);
+ gpio_export_with_name(METER_CTL, true, "meter_ctl");
+
+ gpio_request(METER_RESERV, "meter_reserv");
+ mt_set_gpio_dir(METER_RESERV, 1);
+ gpio_export_with_name(METER_RESERV, true, "meter_reserv");
+
+ gpio_request(NLS_RST, "nls_rst");
+ mt_set_gpio_dir(NLS_RST, 1);
+ gpio_export_with_name(NLS_RST, true, "nls_rst");
+
+ gpio_request(NLS_TRIG, "nls_trig");
+ mt_set_gpio_dir(NLS_TRIG, 1);
+ gpio_export_with_name(NLS_TRIG, true, "nls_trig");
+
+ gpio_request(PINGOPIN_EN, "pingopin_en");
+ mt_set_gpio_dir(PINGOPIN_EN, 1);
+ gpio_export_with_name(PINGOPIN_EN, true, "pingopin_en");
+
+ gpio_request(PWR_PINGOPIN, "pwr_pingopin");
+ mt_set_gpio_dir(PWR_PINGOPIN, 1);
+ gpio_export_with_name(PWR_PINGOPIN, true, "pwr_pingopin");
+
+ gpio_request(PWR_UART, "pwr_uart");
+ mt_set_gpio_dir(PWR_UART, 1);
+ gpio_export_with_name(PWR_UART, true, "pwr_uart");
+
+ gpio_request(UART_EN, "uart_en");
+ mt_set_gpio_dir(UART_EN, 1);
+ gpio_export_with_name(UART_EN, true, "uart_en");
+}
+
static int aeon_gpio_probe(struct platform_device *pdev)
{
int ret = 0;
@@ -161,6 +221,9 @@ static int aeon_gpio_probe(struct platform_device *pdev)
AEON_ERR("%s : Cannot find gpio pinctrl!\n", __func__);
}
+printk("Jason in func:%s\n", __func__);
+ custom_gpio_init();
+
return ret;
}
@@ -220,4 +283,4 @@ module_exit(eastaeon_gpio_exit);
//MODULE_DESCRIPTION("eastaeon gpio driver");
//MODULE_AUTHOR("sanford lin <lin.xiufa@eastaeon.com>");
-//MODULE_LICENSE("GPL");
\ No newline at end of file
+//MODULE_LICENSE("GPL");
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d38a294..ccdbe49 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -113,7 +113,8 @@ static inline int __gpio_to_irq(unsigned gpio)
extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
extern int gpio_request_array(const struct gpio *array, size_t num);
extern void gpio_free_array(const struct gpio *array, size_t num);
-
+extern int gpiod_export_with_name(struct gpio_desc *desc, bool direction_may_change,
+ const char *name);
/*
* A sysfs interface can be exported by individual drivers if they want,
* but more typically is configured entirely from userspace.
@@ -123,6 +124,12 @@ static inline int gpio_export(unsigned gpio, bool direction_may_change)
return gpiod_export(gpio_to_desc(gpio), direction_may_change);
}
+static inline int gpio_export_with_name(unsigned gpio, bool direction_may_change,
+ const char *name)
+{
+ return gpiod_export_with_name(gpio_to_desc(gpio), direction_may_change, name);
+}
+
static inline int gpio_export_link(struct device *dev, const char *name,
unsigned gpio)
{
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 85aa5d0..a43c7e6 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -188,6 +188,14 @@ static inline int gpio_export(unsigned gpio, bool direction_may_change)
return -EINVAL;
}
+static inline int gpio_export_with_name(unsigned gpio, bool direction_may_change,
+ const char *name)
+{
+ /* GPIO can never have been requested or set as {in,out}put */
+ WARN_ON(1);
+ return -EINVAL;
+}
+
static inline int gpio_export_link(struct device *dev, const char *name,
unsigned gpio)
{
diff --git a/tools/dct/old_dct/Keypad_YuSu.cmp b/tools/dct/old_dct/Keypad_YuSu.cmp
index 0986f7e..b63e689 100644
--- a/tools/dct/old_dct/Keypad_YuSu.cmp
+++ b/tools/dct/old_dct/Keypad_YuSu.cmp
@@ -67,7 +67,7 @@ KEY_W
KEY_X
KEY_Y
KEY_Z
-
+KEY_F14
[Key_code]
0
228
--
1.9.1