mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
kernel:input: remotectl remove ir key struct to dts and handle ir irq not on cpu0
This commit is contained in:
97
arch/arm/boot/dts/rk3036-sdk.dts
Normal file → Executable file
97
arch/arm/boot/dts/rk3036-sdk.dts
Normal file → Executable file
@@ -221,3 +221,100 @@
|
||||
&pwm2 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&remotectl {
|
||||
handle_cpu_id = <1>;
|
||||
ir_key1{
|
||||
compatible = "rockchip,ir_key";
|
||||
rockchip,usercode = <0x4040>;
|
||||
rockchip,key_table =
|
||||
<0xf2 KEY_REPLY>,
|
||||
<0xba KEY_BACK>,
|
||||
<0xf4 KEY_UP>,
|
||||
<0xf1 KEY_DOWN>,
|
||||
<0xef KEY_LEFT>,
|
||||
<0xee KEY_RIGHT>,
|
||||
<0xbd KEY_HOME>,
|
||||
<0xea KEY_VOLUMEUP>,
|
||||
<0xe3 KEY_VOLUMEDOWN>,
|
||||
<0xe2 KEY_SEARCH>,
|
||||
<0xb2 KEY_POWER>,
|
||||
<0xbc KEY_MUTE>,
|
||||
<0xec KEY_MENU>,
|
||||
<0xbf 0x190>,
|
||||
<0xe0 0x191>,
|
||||
<0xe1 0x192>,
|
||||
<0xe9 183>,
|
||||
<0xe6 248>,
|
||||
<0xe8 185>,
|
||||
<0xe7 186>,
|
||||
<0xf0 388>,
|
||||
<0xbe 0x175>;
|
||||
};
|
||||
ir_key2{
|
||||
compatible = "rockchip,ir_key";
|
||||
rockchip,usercode = <0xff00>;
|
||||
rockchip,key_table =
|
||||
<0xf9 KEY_HOME>,
|
||||
<0xbf KEY_BACK>,
|
||||
<0xfb KEY_MENU>,
|
||||
<0xaa KEY_REPLY>,
|
||||
<0xb9 KEY_UP>,
|
||||
<0xe9 KEY_DOWN>,
|
||||
<0xb8 KEY_LEFT>,
|
||||
<0xea KEY_RIGHT>,
|
||||
<0xeb KEY_VOLUMEDOWN>,
|
||||
<0xef KEY_VOLUMEUP>,
|
||||
<0xf7 KEY_MUTE>,
|
||||
<0xe7 KEY_POWER>,
|
||||
<0xfc KEY_POWER>,
|
||||
<0xa9 KEY_VOLUMEDOWN>,
|
||||
<0xa8 KEY_VOLUMEDOWN>,
|
||||
<0xe0 KEY_VOLUMEDOWN>,
|
||||
<0xa5 KEY_VOLUMEDOWN>,
|
||||
<0xab 183>,
|
||||
<0xb7 388>,
|
||||
<0xf8 184>,
|
||||
<0xaf 185>,
|
||||
<0xed KEY_VOLUMEDOWN>,
|
||||
<0xee 186>,
|
||||
<0xb3 KEY_VOLUMEDOWN>,
|
||||
<0xf1 KEY_VOLUMEDOWN>,
|
||||
<0xf2 KEY_VOLUMEDOWN>,
|
||||
<0xf3 KEY_SEARCH>,
|
||||
<0xb4 KEY_VOLUMEDOWN>,
|
||||
<0xbe KEY_SEARCH>;
|
||||
};
|
||||
ir_key3{
|
||||
compatible = "rockchip,ir_key";
|
||||
rockchip,usercode = <0x1dcc>;
|
||||
rockchip,key_table =
|
||||
<0xee KEY_REPLY>,
|
||||
<0xf0 KEY_BACK>,
|
||||
<0xf8 KEY_UP>,
|
||||
<0xbb KEY_DOWN>,
|
||||
<0xef KEY_LEFT>,
|
||||
<0xed KEY_RIGHT>,
|
||||
<0xfc KEY_HOME>,
|
||||
<0xf1 KEY_VOLUMEUP>,
|
||||
<0xfd KEY_VOLUMEDOWN>,
|
||||
<0xb7 KEY_SEARCH>,
|
||||
<0xff KEY_POWER>,
|
||||
<0xf3 KEY_MUTE>,
|
||||
<0xbf KEY_MENU>,
|
||||
<0xf9 0x191>,
|
||||
<0xf5 0x192>,
|
||||
<0xb3 388>,
|
||||
<0xbe KEY_1>,
|
||||
<0xba KEY_2>,
|
||||
<0xb2 KEY_3>,
|
||||
<0xbd KEY_4>,
|
||||
<0xf9 KEY_5>,
|
||||
<0xb1 KEY_6>,
|
||||
<0xfc KEY_7>,
|
||||
<0xf8 KEY_8>,
|
||||
<0xb0 KEY_9>,
|
||||
<0xb6 KEY_0>,
|
||||
<0xb5 KEY_BACKSPACE>;
|
||||
};
|
||||
};
|
||||
@@ -465,6 +465,7 @@
|
||||
pinctrl-0 = <&pwm3_pin>;
|
||||
clocks = <&clk_gates7 10>;
|
||||
clock-names = "pclk_pwm";
|
||||
remote_pwm_id = <3>;
|
||||
interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "rk312x-sdk.dtsi"
|
||||
#include "lcd-box.dtsi"
|
||||
#include <dt-bindings/input/input.h>
|
||||
|
||||
/ {
|
||||
compatible = "rockchip,rk3128";
|
||||
@@ -286,6 +287,104 @@
|
||||
};
|
||||
|
||||
&sdmmc {
|
||||
status = "disabled";
|
||||
status = "disabled";
|
||||
cd-gpios = <&gpio1 GPIO_C1 GPIO_ACTIVE_HIGH>;/*CD GPIO*/
|
||||
};
|
||||
|
||||
&remotectl {
|
||||
handle_cpu_id = <1>;
|
||||
ir_key1{
|
||||
compatible = "rockchip,ir_key";
|
||||
rockchip,usercode = <0x4040>;
|
||||
rockchip,key_table =
|
||||
<0xf2 KEY_REPLY>,
|
||||
<0xba KEY_BACK>,
|
||||
<0xf4 KEY_UP>,
|
||||
<0xf1 KEY_DOWN>,
|
||||
<0xef KEY_LEFT>,
|
||||
<0xee KEY_RIGHT>,
|
||||
<0xbd KEY_HOME>,
|
||||
<0xea KEY_VOLUMEUP>,
|
||||
<0xe3 KEY_VOLUMEDOWN>,
|
||||
<0xe2 KEY_SEARCH>,
|
||||
<0xb2 KEY_POWER>,
|
||||
<0xbc KEY_MUTE>,
|
||||
<0xec KEY_MENU>,
|
||||
<0xbf 0x190>,
|
||||
<0xe0 0x191>,
|
||||
<0xe1 0x192>,
|
||||
<0xe9 183>,
|
||||
<0xe6 248>,
|
||||
<0xe8 185>,
|
||||
<0xe7 186>,
|
||||
<0xf0 388>,
|
||||
<0xbe 0x175>;
|
||||
};
|
||||
ir_key2{
|
||||
compatible = "rockchip,ir_key";
|
||||
rockchip,usercode = <0xff00>;
|
||||
rockchip,key_table =
|
||||
<0xf9 KEY_HOME>,
|
||||
<0xbf KEY_BACK>,
|
||||
<0xfb KEY_MENU>,
|
||||
<0xaa KEY_REPLY>,
|
||||
<0xb9 KEY_UP>,
|
||||
<0xe9 KEY_DOWN>,
|
||||
<0xb8 KEY_LEFT>,
|
||||
<0xea KEY_RIGHT>,
|
||||
<0xeb KEY_VOLUMEDOWN>,
|
||||
<0xef KEY_VOLUMEUP>,
|
||||
<0xf7 KEY_MUTE>,
|
||||
<0xe7 KEY_POWER>,
|
||||
<0xfc KEY_POWER>,
|
||||
<0xa9 KEY_VOLUMEDOWN>,
|
||||
<0xa8 KEY_VOLUMEDOWN>,
|
||||
<0xe0 KEY_VOLUMEDOWN>,
|
||||
<0xa5 KEY_VOLUMEDOWN>,
|
||||
<0xab 183>,
|
||||
<0xb7 388>,
|
||||
<0xf8 184>,
|
||||
<0xaf 185>,
|
||||
<0xed KEY_VOLUMEDOWN>,
|
||||
<0xee 186>,
|
||||
<0xb3 KEY_VOLUMEDOWN>,
|
||||
<0xf1 KEY_VOLUMEDOWN>,
|
||||
<0xf2 KEY_VOLUMEDOWN>,
|
||||
<0xf3 KEY_SEARCH>,
|
||||
<0xb4 KEY_VOLUMEDOWN>,
|
||||
<0xbe KEY_SEARCH>;
|
||||
};
|
||||
/*
|
||||
ir_key3{
|
||||
compatible = "rockchip,ir_key";
|
||||
rockchip,usercode = <0x1dcc>;
|
||||
rockchip,key_table =
|
||||
<0xee KEY_REPLY>,
|
||||
<0xf0 KEY_BACK>,
|
||||
<0xf8 KEY_UP>,
|
||||
<0xbb KEY_DOWN>,
|
||||
<0xef KEY_LEFT>,
|
||||
<0xed KEY_RIGHT>,
|
||||
<0xfc KEY_HOME>,
|
||||
<0xf1 KEY_VOLUMEUP>,
|
||||
<0xfd KEY_VOLUMEDOWN>,
|
||||
<0xb7 KEY_SEARCH>,
|
||||
<0xff KEY_POWER>,
|
||||
<0xf3 KEY_MUTE>,
|
||||
<0xbf KEY_MENU>,
|
||||
<0xf9 0x191>,
|
||||
<0xf5 0x192>,
|
||||
<0xb3 388>,
|
||||
<0xbe KEY_1>,
|
||||
<0xba KEY_2>,
|
||||
<0xb2 KEY_3>,
|
||||
<0xbd KEY_4>,
|
||||
<0xf9 KEY_5>,
|
||||
<0xb1 KEY_6>,
|
||||
<0xfc KEY_7>,
|
||||
<0xf8 KEY_8>,
|
||||
<0xb0 KEY_9>,
|
||||
<0xb6 KEY_0>,
|
||||
<0xb5 KEY_BACKSPACE>;
|
||||
};*/
|
||||
};
|
||||
@@ -661,6 +661,7 @@
|
||||
pinctrl-0 = <&pwm3_pin>;
|
||||
clocks = <&clk_gates7 10>;
|
||||
clock-names = "pclk_pwm";
|
||||
remote_pwm_id = <3>;
|
||||
interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <linux/input.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/wakelock.h>
|
||||
#include <linux/slab.h>
|
||||
#include "rockchip_pwm_remotectl.h"
|
||||
|
||||
|
||||
@@ -44,7 +45,7 @@ struct rkxx_remote_key_table {
|
||||
struct rkxx_remotectl_button {
|
||||
int usercode;
|
||||
int nbuttons;
|
||||
struct rkxx_remote_key_table *key_table;
|
||||
struct rkxx_remote_key_table key_table[MAX_NUM_KEYS];
|
||||
};
|
||||
|
||||
struct rkxx_remotectl_drvdata {
|
||||
@@ -55,11 +56,14 @@ struct rkxx_remotectl_drvdata {
|
||||
int scandata;
|
||||
int count;
|
||||
int keynum;
|
||||
int maxkeybdnum;
|
||||
int keycode;
|
||||
int press;
|
||||
int pre_press;
|
||||
int period;
|
||||
int irq;
|
||||
int remote_pwm_id;
|
||||
int handle_cpu_id;
|
||||
int wakeup;
|
||||
struct input_dev *input;
|
||||
struct timer_list timer;
|
||||
@@ -67,124 +71,7 @@ struct rkxx_remotectl_drvdata {
|
||||
struct wake_lock remotectl_wake_lock;
|
||||
};
|
||||
|
||||
|
||||
static struct rkxx_remote_key_table remote_key_table_meiyu_4040[] = {
|
||||
{0xf2, KEY_REPLY},
|
||||
{0xba, KEY_BACK},
|
||||
{0xf4, KEY_UP},
|
||||
{0xf1, KEY_DOWN},
|
||||
{0xef, KEY_LEFT},
|
||||
{0xee, KEY_RIGHT},
|
||||
{0xbd, KEY_HOME},
|
||||
{0xea, KEY_VOLUMEUP},
|
||||
{0xe3, KEY_VOLUMEDOWN},
|
||||
{0xe2, KEY_SEARCH},
|
||||
{0xb2, KEY_POWER},
|
||||
{0xbc, KEY_MUTE},
|
||||
{0xec, KEY_MENU},
|
||||
/*lay pause*/
|
||||
{0xbf, 0x190},
|
||||
/*pre*/
|
||||
{0xe0, 0x191},
|
||||
/*next*/
|
||||
{0xe1, 0x192},
|
||||
/*pic,rorate left*/
|
||||
{0xe9, 183},
|
||||
/*rorate right*/
|
||||
{0xe6, 248},
|
||||
/*zoom out*/
|
||||
{0xe8, 185},
|
||||
/*zoom in*/
|
||||
{0xe7, 186},
|
||||
/*mouse switch*/
|
||||
{0xb8, 388},
|
||||
/*zoom outdisplay switch*/
|
||||
{0xbe, 0x175},
|
||||
};
|
||||
|
||||
|
||||
static struct rkxx_remote_key_table remote_key_table_sunchip_ff00[] = {
|
||||
{0xf9, KEY_HOME},
|
||||
{0xbf, KEY_BACK},
|
||||
{0xfb, KEY_MENU},
|
||||
{0xaa, KEY_REPLY},
|
||||
{0xb9, KEY_UP},
|
||||
{0xe9, KEY_DOWN},
|
||||
{0xb8, KEY_LEFT},
|
||||
{0xea, KEY_RIGHT},
|
||||
{0xeb, KEY_VOLUMEDOWN},
|
||||
{0xef, KEY_VOLUMEUP},
|
||||
{0xf7, KEY_MUTE},
|
||||
{0xe7, KEY_POWER},
|
||||
{0xfc, KEY_POWER},
|
||||
{0xa9, KEY_VOLUMEDOWN},
|
||||
{0xa8, KEY_VOLUMEDOWN},
|
||||
{0xe0, KEY_VOLUMEDOWN},
|
||||
{0xa5, KEY_VOLUMEDOWN},
|
||||
{0xab, 183},
|
||||
{0xb7, 388},
|
||||
{0xf8, 184},
|
||||
{0xaf, 185},
|
||||
{0xed, KEY_VOLUMEDOWN},
|
||||
{0xee, 186},
|
||||
{0xb3, KEY_VOLUMEDOWN},
|
||||
{0xf1, KEY_VOLUMEDOWN},
|
||||
{0xf2, KEY_VOLUMEDOWN},
|
||||
{0xf3, KEY_SEARCH},
|
||||
{0xb4, KEY_VOLUMEDOWN},
|
||||
{0xbe, KEY_SEARCH},
|
||||
};
|
||||
|
||||
|
||||
|
||||
static struct rkxx_remote_key_table remote_key_table_0x1dcc[] = {
|
||||
{0xee, KEY_REPLY},
|
||||
{0xf0, KEY_BACK},
|
||||
{0xf8, KEY_UP},
|
||||
{0xbb, KEY_DOWN},
|
||||
{0xef, KEY_LEFT},
|
||||
{0xed, KEY_RIGHT},
|
||||
{0xfc, KEY_HOME},
|
||||
{0xf1, KEY_VOLUMEUP},
|
||||
{0xfd, KEY_VOLUMEDOWN},
|
||||
{0xb7, KEY_SEARCH},
|
||||
{0xff, KEY_POWER},
|
||||
{0xf3, KEY_MUTE},
|
||||
{0xbf, KEY_MENU},
|
||||
{0xf9, 0x191},
|
||||
{0xf5, 0x192},
|
||||
{0xb3, 388},
|
||||
{0xbe, KEY_1},
|
||||
{0xba, KEY_2},
|
||||
{0xb2, KEY_3},
|
||||
{0xbd, KEY_4},
|
||||
{0xf9, KEY_5},
|
||||
{0xb1, KEY_6},
|
||||
{0xfc, KEY_7},
|
||||
{0xf8, KEY_8},
|
||||
{0xb0, KEY_9},
|
||||
{0xb6, KEY_0},
|
||||
{0xb5, KEY_BACKSPACE},
|
||||
};
|
||||
|
||||
|
||||
static struct rkxx_remotectl_button remotectl_button[] = {
|
||||
{
|
||||
.usercode = 0xff00,
|
||||
.nbuttons = 29,
|
||||
.key_table = &remote_key_table_sunchip_ff00[0],
|
||||
},
|
||||
{
|
||||
.usercode = 0x4040,
|
||||
.nbuttons = 22,
|
||||
.key_table = &remote_key_table_meiyu_4040[0],
|
||||
},
|
||||
{
|
||||
.usercode = 0x1dcc,
|
||||
.nbuttons = 27,
|
||||
.key_table = &remote_key_table_0x1dcc[0],
|
||||
},
|
||||
};
|
||||
static struct rkxx_remotectl_button *remotectl_button;
|
||||
|
||||
|
||||
static int remotectl_keybd_num_lookup(struct rkxx_remotectl_drvdata *ddata)
|
||||
@@ -192,7 +79,7 @@ static int remotectl_keybd_num_lookup(struct rkxx_remotectl_drvdata *ddata)
|
||||
int i;
|
||||
int num;
|
||||
|
||||
num = sizeof(remotectl_button)/sizeof(struct rkxx_remotectl_button);
|
||||
num = ddata->maxkeybdnum;
|
||||
for (i = 0; i < num; i++) {
|
||||
if (remotectl_button[i].usercode == (ddata->scandata&0xFFFF)) {
|
||||
ddata->keynum = i;
|
||||
@@ -220,6 +107,52 @@ static int remotectl_keycode_lookup(struct rkxx_remotectl_drvdata *ddata)
|
||||
}
|
||||
|
||||
|
||||
static int rk_remotectl_parse_ir_keys(struct platform_device *pdev)
|
||||
{
|
||||
struct rkxx_remotectl_drvdata *ddata = platform_get_drvdata(pdev);
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
struct device_node *child_node;
|
||||
u32 loop;
|
||||
u32 ret;
|
||||
u32 len;
|
||||
u32 boardnum;
|
||||
|
||||
boardnum = 0;
|
||||
for_each_child_of_node(node, child_node) {
|
||||
if(of_property_read_u32(child_node, "rockchip,usercode",
|
||||
&remotectl_button[boardnum].usercode)) {
|
||||
dev_err(&pdev->dev, "Missing usercode property in the DTS.\n");
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
DBG("remotectl_button[0].usercode=0x%x\n",
|
||||
remotectl_button[boardnum].usercode);
|
||||
of_get_property(child_node, "rockchip,key_table", &len);
|
||||
len /= sizeof(u32);
|
||||
DBG("len=0x%x\n",len);
|
||||
remotectl_button[boardnum].nbuttons = len/2;
|
||||
if(of_property_read_u32_array(child_node, "rockchip,key_table",
|
||||
(u32 *)remotectl_button[boardnum].key_table, len)) {
|
||||
dev_err(&pdev->dev, "Missing key_table property in the DTS.\n");
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
for (loop=0; loop<(len/2); loop++) {
|
||||
DBG("board[%d].scanCode[%d]=0x%x\n", boardnum, loop,
|
||||
remotectl_button[boardnum].key_table[loop].scancode);
|
||||
DBG("board[%d].keyCode[%d]=%d\n", boardnum, loop,
|
||||
remotectl_button[boardnum].key_table[loop].keycode);
|
||||
}
|
||||
boardnum++;
|
||||
if (boardnum > ddata->maxkeybdnum)
|
||||
break;
|
||||
}
|
||||
DBG("keybdNum=0x%x\n",boardnum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void rk_pwm_remotectl_do_something(unsigned long data)
|
||||
{
|
||||
struct rkxx_remotectl_drvdata *ddata;
|
||||
@@ -336,22 +269,86 @@ static irqreturn_t rockchip_pwm_irq(int irq, void *dev_id)
|
||||
int val;
|
||||
|
||||
ddata = (struct rkxx_remotectl_drvdata *)dev_id;
|
||||
val = readl_relaxed(ddata->base + PWM_REG_INTSTS);
|
||||
if (val&PWM_CH3_INT) {
|
||||
if ((val & PWM_CH3_POL) == 0) {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_HPR);
|
||||
ddata->period = val;
|
||||
tasklet_hi_schedule(&ddata->remote_tasklet);
|
||||
DBG("hpr=0x%x\n", val);
|
||||
} else {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_LPR);
|
||||
DBG("lpr=0x%x\n", val);
|
||||
switch (ddata->remote_pwm_id) {
|
||||
case 0: {
|
||||
val = readl_relaxed(ddata->base + PWM0_REG_INTSTS);
|
||||
if (val & PWM_CH0_INT) {
|
||||
if ((val & PWM_CH0_POL) == 0) {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_HPR);
|
||||
ddata->period = val;
|
||||
tasklet_hi_schedule(&ddata->remote_tasklet);
|
||||
DBG("hpr=0x%x\n", val);
|
||||
} else {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_LPR);
|
||||
DBG("lpr=0x%x\n", val);
|
||||
}
|
||||
writel_relaxed(PWM_CH0_INT, ddata->base + PWM0_REG_INTSTS);
|
||||
if (ddata->state == RMC_PRELOAD)
|
||||
wake_lock_timeout(&ddata->remotectl_wake_lock, HZ);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
writel_relaxed(PWM_CH3_INT, ddata->base + PWM_REG_INTSTS);
|
||||
if (ddata->state == RMC_PRELOAD)
|
||||
wake_lock_timeout(&ddata->remotectl_wake_lock, HZ);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
break;
|
||||
case 1: {
|
||||
val = readl_relaxed(ddata->base + PWM1_REG_INTSTS);
|
||||
if (val & PWM_CH1_INT) {
|
||||
if ((val & PWM_CH1_POL) == 0) {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_HPR);
|
||||
ddata->period = val;
|
||||
tasklet_hi_schedule(&ddata->remote_tasklet);
|
||||
DBG("hpr=0x%x\n", val);
|
||||
} else {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_LPR);
|
||||
DBG("lpr=0x%x\n", val);
|
||||
}
|
||||
writel_relaxed(PWM_CH1_INT, ddata->base + PWM1_REG_INTSTS);
|
||||
if (ddata->state == RMC_PRELOAD)
|
||||
wake_lock_timeout(&ddata->remotectl_wake_lock, HZ);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
val = readl_relaxed(ddata->base + PWM2_REG_INTSTS);
|
||||
if (val & PWM_CH2_INT) {
|
||||
if ((val & PWM_CH2_POL) == 0) {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_HPR);
|
||||
ddata->period = val;
|
||||
tasklet_hi_schedule(&ddata->remote_tasklet);
|
||||
DBG("hpr=0x%x\n", val);
|
||||
} else {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_LPR);
|
||||
DBG("lpr=0x%x\n", val);
|
||||
}
|
||||
writel_relaxed(PWM_CH2_INT, ddata->base + PWM2_REG_INTSTS);
|
||||
if (ddata->state == RMC_PRELOAD)
|
||||
wake_lock_timeout(&ddata->remotectl_wake_lock, HZ);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3: {
|
||||
val = readl_relaxed(ddata->base + PWM3_REG_INTSTS);
|
||||
if (val & PWM_CH3_INT) {
|
||||
if ((val & PWM_CH3_POL) == 0) {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_HPR);
|
||||
ddata->period = val;
|
||||
tasklet_hi_schedule(&ddata->remote_tasklet);
|
||||
DBG("hpr=0x%x\n", val);
|
||||
} else {
|
||||
val = readl_relaxed(ddata->base + PWM_REG_LPR);
|
||||
DBG("lpr=0x%x\n", val);
|
||||
}
|
||||
writel_relaxed(PWM_CH3_INT, ddata->base + PWM3_REG_INTSTS);
|
||||
if (ddata->state == RMC_PRELOAD)
|
||||
wake_lock_timeout(&ddata->remotectl_wake_lock, HZ);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
@@ -368,9 +365,34 @@ static int rk_pwm_remotectl_hw_init(struct rkxx_remotectl_drvdata *ddata)
|
||||
val = readl_relaxed(ddata->base + PWM_REG_CTRL);
|
||||
val = (val & 0xFF008DFF) | 0x00646200;
|
||||
writel_relaxed(val, ddata->base + PWM_REG_CTRL);
|
||||
val = readl_relaxed(ddata->base + PWM_REG_INT_EN);
|
||||
val = (val & 0xFFFFFFF7) | PWM_CH3_INT_ENABLE;
|
||||
writel_relaxed(val, ddata->base + PWM_REG_INT_EN);
|
||||
switch (ddata->remote_pwm_id) {
|
||||
case 0: {
|
||||
val = readl_relaxed(ddata->base + PWM0_REG_INT_EN);
|
||||
val = (val & 0xFFFFFFFE) | PWM_CH0_INT_ENABLE;
|
||||
writel_relaxed(val, ddata->base + PWM0_REG_INT_EN);
|
||||
}
|
||||
break;
|
||||
case 1: {
|
||||
val = readl_relaxed(ddata->base + PWM1_REG_INT_EN);
|
||||
val = (val & 0xFFFFFFFD) | PWM_CH1_INT_ENABLE;
|
||||
writel_relaxed(val, ddata->base + PWM1_REG_INT_EN);
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
val = readl_relaxed(ddata->base + PWM2_REG_INT_EN);
|
||||
val = (val & 0xFFFFFFFB) | PWM_CH2_INT_ENABLE;
|
||||
writel_relaxed(val, ddata->base + PWM2_REG_INT_EN);
|
||||
}
|
||||
break;
|
||||
case 3: {
|
||||
val = readl_relaxed(ddata->base + PWM3_REG_INT_EN);
|
||||
val = (val & 0xFFFFFFF7) | PWM_CH3_INT_ENABLE;
|
||||
writel_relaxed(val, ddata->base + PWM3_REG_INT_EN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
val = readl_relaxed(ddata->base + PWM_REG_CTRL);
|
||||
val = (val & 0xFFFFFFFE) | PWM_ENABLE;
|
||||
writel_relaxed(val, ddata->base + PWM_REG_CTRL);
|
||||
@@ -382,15 +404,20 @@ static int rk_pwm_remotectl_hw_init(struct rkxx_remotectl_drvdata *ddata)
|
||||
static int rk_pwm_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct rkxx_remotectl_drvdata *ddata;
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
struct device_node *child_node;
|
||||
struct resource *r;
|
||||
struct input_dev *input;
|
||||
struct clk *clk;
|
||||
struct cpumask cpumask;
|
||||
int num;
|
||||
int irq;
|
||||
int ret;
|
||||
int i, j;
|
||||
|
||||
DBG(".. rk pwm remotectl v1.1 init\n");
|
||||
int cpu_id;
|
||||
int pwm_id;
|
||||
|
||||
pr_err(".. rk pwm remotectl v1.1 init\n");
|
||||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!r) {
|
||||
dev_err(&pdev->dev, "no memory resources defined\n");
|
||||
@@ -410,6 +437,23 @@ static int rk_pwm_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
platform_set_drvdata(pdev, ddata);
|
||||
num = 0;
|
||||
for_each_child_of_node(np, child_node){
|
||||
if(of_device_is_compatible(child_node, "rockchip,ir_key"))
|
||||
num++;
|
||||
}
|
||||
if (num == 0) {
|
||||
pr_err("remotectl: no ir keyboard add in dts!!\n");
|
||||
return -1;
|
||||
}
|
||||
ddata->maxkeybdnum = num;
|
||||
remotectl_button = kmalloc(
|
||||
num*sizeof(struct rkxx_remotectl_button),
|
||||
GFP_KERNEL);
|
||||
if (!remotectl_button) {
|
||||
pr_err("failed to malloc remote button memory\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
input = input_allocate_device();
|
||||
input->name = pdev->name;
|
||||
input->phys = "gpio-keys/remotectl";
|
||||
@@ -432,9 +476,15 @@ static int rk_pwm_probe(struct platform_device *pdev)
|
||||
}
|
||||
ddata->irq = irq;
|
||||
ddata->wakeup = 1;
|
||||
of_property_read_u32(np, "remote_pwm_id", &pwm_id);
|
||||
ddata->remote_pwm_id = pwm_id;
|
||||
DBG("remotectl: remote pwm id=0x%x\n", pwm_id);
|
||||
of_property_read_u32(np, "handle_cpu_id", &cpu_id);
|
||||
ddata->handle_cpu_id = cpu_id;
|
||||
DBG("remotectl: handle cpu id=0x%x\n", cpu_id);
|
||||
rk_remotectl_parse_ir_keys(pdev);
|
||||
tasklet_init(&ddata->remote_tasklet, rk_pwm_remotectl_do_something,
|
||||
(unsigned long)ddata);
|
||||
num = sizeof(remotectl_button)/sizeof(struct rkxx_remotectl_button);
|
||||
for (j = 0; j < num; j++) {
|
||||
DBG("remotectl probe j = 0x%x\n", j);
|
||||
for (i = 0; i < remotectl_button[j].nbuttons; i++) {
|
||||
@@ -459,6 +509,9 @@ static int rk_pwm_probe(struct platform_device *pdev)
|
||||
setup_timer(&ddata->timer, rk_pwm_remotectl_timer,
|
||||
(unsigned long)ddata);
|
||||
mod_timer(&ddata->timer, jiffies + msecs_to_jiffies(1000));
|
||||
cpumask_clear(&cpumask);
|
||||
cpumask_set_cpu(cpu_id, &cpumask);
|
||||
irq_set_affinity(irq, &cpumask);
|
||||
rk_pwm_remotectl_hw_init(ddata);
|
||||
return ret;
|
||||
}
|
||||
@@ -468,6 +521,38 @@ static int rk_pwm_remove(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int remotectl_suspend(struct device *dev)
|
||||
{
|
||||
int cpu = 0;
|
||||
struct cpumask cpumask;
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct rkxx_remotectl_drvdata *ddata = platform_get_drvdata(pdev);
|
||||
|
||||
cpumask_clear(&cpumask);
|
||||
cpumask_set_cpu(cpu, &cpumask);
|
||||
irq_set_affinity(ddata->irq, &cpumask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int remotectl_resume(struct device *dev)
|
||||
{
|
||||
struct cpumask cpumask;
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct rkxx_remotectl_drvdata *ddata = platform_get_drvdata(pdev);
|
||||
|
||||
cpumask_clear(&cpumask);
|
||||
cpumask_set_cpu(ddata->handle_cpu_id, &cpumask);
|
||||
irq_set_affinity(ddata->irq, &cpumask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops remotectl_pm_ops = {
|
||||
.suspend = remotectl_suspend,
|
||||
.resume = remotectl_resume,
|
||||
};
|
||||
#endif
|
||||
|
||||
static const struct of_device_id rk_pwm_of_match[] = {
|
||||
{ .compatible = "rockchip,remotectl-pwm"},
|
||||
@@ -480,6 +565,9 @@ static struct platform_driver rk_pwm_driver = {
|
||||
.driver = {
|
||||
.name = "remotectl-pwm",
|
||||
.of_match_table = rk_pwm_of_match,
|
||||
#ifdef CONFIG_PM
|
||||
.pm = &remotectl_pm_ops,
|
||||
#endif
|
||||
},
|
||||
.probe = rk_pwm_probe,
|
||||
.remove = rk_pwm_remove,
|
||||
|
||||
@@ -3,14 +3,21 @@
|
||||
#define __RKXX_PWM_REMOTECTL_H__
|
||||
#include <linux/input.h>
|
||||
|
||||
#define MAX_NUM_KEYS 60
|
||||
|
||||
/* PWM0 registers */
|
||||
#define PWM_REG_CNTR 0x00 /* Counter Register */
|
||||
#define PWM_REG_HPR 0x04 /* Period Register */
|
||||
#define PWM_REG_LPR 0x08 /* Duty Cycle Register */
|
||||
#define PWM_REG_CTRL 0x0c /* Control Register */
|
||||
#define PWM_REG_INTSTS 0x10 /* Interrupt Status Refister */
|
||||
#define PWM_REG_INT_EN 0x14 /* Interrupt Enable Refister */
|
||||
|
||||
#define PWM3_REG_INTSTS 0x10 /* Interrupt Status Refister For Pwm3*/
|
||||
#define PWM2_REG_INTSTS 0x20 /* Interrupt Status Refister For Pwm2*/
|
||||
#define PWM1_REG_INTSTS 0x30 /* Interrupt Status Refister For Pwm1*/
|
||||
#define PWM0_REG_INTSTS 0x40 /* Interrupt Status Refister For Pwm0*/
|
||||
#define PWM3_REG_INT_EN 0x14 /* Interrupt Enable Refister For Pwm3*/
|
||||
#define PWM2_REG_INT_EN 0x24 /* Interrupt Enable Refister For Pwm2*/
|
||||
#define PWM1_REG_INT_EN 0x34 /* Interrupt Enable Refister For Pwm1*/
|
||||
#define PWM0_REG_INT_EN 0x44 /* Interrupt Enable Refister For Pwm0*/
|
||||
|
||||
/*REG_CTRL bits definitions*/
|
||||
#define PWM_ENABLE (1 << 0)
|
||||
|
||||
78
include/dt-bindings/input/input.h
Executable file
78
include/dt-bindings/input/input.h
Executable file
@@ -0,0 +1,78 @@
|
||||
#define KEY_RESERVED 0
|
||||
#define KEY_ESC 1
|
||||
#define KEY_1 2
|
||||
#define KEY_2 3
|
||||
#define KEY_3 4
|
||||
#define KEY_4 5
|
||||
#define KEY_5 6
|
||||
#define KEY_6 7
|
||||
#define KEY_7 8
|
||||
#define KEY_8 9
|
||||
#define KEY_9 10
|
||||
#define KEY_0 11
|
||||
#define KEY_MINUS 12
|
||||
#define KEY_EQUAL 13
|
||||
#define KEY_BACKSPACE 14
|
||||
#define KEY_TAB 15
|
||||
#define KEY_Q 16
|
||||
#define KEY_W 17
|
||||
#define KEY_E 18
|
||||
#define KEY_R 19
|
||||
#define KEY_T 20
|
||||
#define KEY_Y 21
|
||||
#define KEY_U 22
|
||||
#define KEY_I 23
|
||||
#define KEY_O 24
|
||||
#define KEY_P 25
|
||||
#define KEY_LEFTBRACE 26
|
||||
#define KEY_RIGHTBRACE 27
|
||||
#define KEY_ENTER 28
|
||||
#define KEY_LEFTCTRL 29
|
||||
#define KEY_A 30
|
||||
#define KEY_S 31
|
||||
#define KEY_D 32
|
||||
#define KEY_F 33
|
||||
#define KEY_G 34
|
||||
#define KEY_H 35
|
||||
#define KEY_J 36
|
||||
#define KEY_K 37
|
||||
#define KEY_L 38
|
||||
#define KEY_SEMICOLON 39
|
||||
#define KEY_APOSTROPHE 40
|
||||
#define KEY_GRAVE 41
|
||||
#define KEY_LEFTSHIFT 42
|
||||
#define KEY_BACKSLASH 43
|
||||
#define KEY_Z 44
|
||||
#define KEY_X 45
|
||||
#define KEY_C 46
|
||||
#define KEY_V 47
|
||||
#define KEY_B 48
|
||||
#define KEY_N 49
|
||||
#define KEY_M 50
|
||||
|
||||
#define KEY_F1 59
|
||||
#define KEY_F2 60
|
||||
#define KEY_F3 61
|
||||
#define KEY_F4 62
|
||||
#define KEY_F5 63
|
||||
#define KEY_F6 64
|
||||
#define KEY_F7 65
|
||||
#define KEY_F8 66
|
||||
#define KEY_F9 67
|
||||
#define KEY_F10 68
|
||||
|
||||
#define KEY_REPLY 232
|
||||
#define KEY_BACK 158
|
||||
#define KEY_UP 103
|
||||
#define KEY_DOWN 108
|
||||
#define KEY_LEFT 105
|
||||
#define KEY_RIGHT 106
|
||||
#define KEY_HOME 102
|
||||
#define KEY_VOLUMEUP 115
|
||||
#define KEY_VOLUMEDOWN 114
|
||||
#define KEY_SEARCH 217
|
||||
#define KEY_POWER 116
|
||||
#define KEY_MUTE 113
|
||||
#define KEY_MENU 139
|
||||
|
||||
|
||||
Reference in New Issue
Block a user