diff --git a/drivers/amlogic/input/remote/remote_meson.h b/drivers/amlogic/input/remote/remote_meson.h index 02534007ae6e..60437d137a20 100644 --- a/drivers/amlogic/input/remote/remote_meson.h +++ b/drivers/amlogic/input/remote/remote_meson.h @@ -167,23 +167,27 @@ enum { }; enum remote_reg { - REG_LDR_ACTIVE = 0x00<<2, - REG_LDR_IDLE = 0x01<<2, - REG_LDR_REPEAT = 0x02<<2, - REG_BIT_0 = 0x03<<2, - REG_REG0 = 0x04<<2, - REG_FRAME = 0x05<<2, - REG_STATUS = 0x06<<2, - REG_REG1 = 0x07<<2, - REG_REG2 = 0x08<<2, - REG_DURATN2 = 0x09<<2, - REG_DURATN3 = 0x0a<<2, - REG_FRAME1 = 0x0b<<2, - REG_STATUS1 = 0x0c<<2, - REG_STATUS2 = 0x0d<<2, - REG_REG3 = 0x0e<<2, - REG_FRAME_RSV0 = 0x0f<<2, - REG_FRAME_RSV1 = 0x10<<2 + REG_LDR_ACTIVE = 0x00 << 2, + REG_LDR_IDLE = 0x01 << 2, + REG_LDR_REPEAT = 0x02 << 2, + REG_BIT_0 = 0x03 << 2, + REG_REG0 = 0x04 << 2, + REG_FRAME = 0x05 << 2, + REG_STATUS = 0x06 << 2, + REG_REG1 = 0x07 << 2, + REG_REG2 = 0x08 << 2, + REG_DURATN2 = 0x09 << 2, + REG_DURATN3 = 0x0a << 2, + REG_FRAME1 = 0x0b << 2, + REG_STATUS1 = 0x0c << 2, + REG_STATUS2 = 0x0d << 2, + REG_REG3 = 0x0e << 2, + REG_FRAME_RSV0 = 0x0f << 2, + REG_FRAME_RSV1 = 0x10 << 2, + REG_FILTE = 0x11 << 2, + REG_IRQ_CTL = 0x12 << 2, + REG_WIDTH_NEW = 0x14 << 2, + REG_REPEAT_DET = 0x15 << 2 }; int ir_register_default_config(struct remote_chip *chip, int type); diff --git a/drivers/amlogic/input/remote/remote_regmap.c b/drivers/amlogic/input/remote/remote_regmap.c index 46715687a7e4..2d9f42404247 100644 --- a/drivers/amlogic/input/remote/remote_regmap.c +++ b/drivers/amlogic/input/remote/remote_regmap.c @@ -134,6 +134,53 @@ static struct remote_reg_map regs_default_rc6[] = { {REG_DURATN3, ((51 << 16) | (38 << 0))}, }; +static struct remote_reg_map regs_default_toshiba[] = { + { REG_LDR_ACTIVE, (280 << 16) | (180 << 0)}, + { REG_LDR_IDLE, (280 << 16) | (180 << 0)}, + { REG_LDR_REPEAT, (150 << 16) | (60 << 0)}, + { REG_BIT_0, (72 << 16) | (40 << 0)}, + { REG_REG0, (7 << 28) | (0xFA0 << 12) | 0x13}, + { REG_STATUS, (134 << 20) | (90 << 10)}, + { REG_REG1, 0x9f00}, + { REG_REG2, (0x05) | (1 << 24) | (23 << 11)}, + { REG_DURATN2, 0x00}, + { REG_DURATN3, 0x00}, + { REG_REPEAT_DET, (1 << 31) | (0xFA0 << 16) | (10 << 0)}, + { REG_REG3, 0x2AF8}, +}; + +static int ir_toshiba_get_scancode(struct remote_chip *chip) +{ + int code = 0; + int decode_status = 0; + int status = 0; + + remote_reg_read(chip, MULTI_IR_ID, REG_STATUS, &decode_status); + if (decode_status & 0x01) + status |= REMOTE_REPEAT; + chip->decode_status = status; /*set decode status*/ + remote_reg_read(chip, MULTI_IR_ID, REG_FRAME, &code); + remote_dbg(chip->dev, "framecode=0x%x\n", code); + chip->r_dev->cur_hardcode = code; + code = (code >> 16) & 0xff; + return code; + +} + +static int ir_toshiba_get_decode_status(struct remote_chip *chip) +{ + int status = chip->decode_status; + return status; +} + +static u32 ir_toshiba_get_custom_code(struct remote_chip *chip) +{ + u32 custom_code; + + custom_code = (chip->r_dev->cur_hardcode) & 0xffff; + return custom_code; +} + void set_hardcode(struct remote_chip *chip, int code) { remote_dbg(chip->dev, "framecode=0x%x\n", code); @@ -499,6 +546,15 @@ static struct aml_remote_reg_proto reg_rc6 = { .get_custom_code = ir_rc6_get_custom_code, }; +static struct aml_remote_reg_proto reg_toshiba = { + .protocol = REMOTE_TYPE_TOSHIBA, + .name = "TOSHIBA", + .reg_map = regs_default_toshiba, + .reg_map_size = ARRAY_SIZE(regs_default_toshiba), + .get_scancode = ir_toshiba_get_scancode, + .get_decode_status = ir_toshiba_get_decode_status, + .get_custom_code = ir_toshiba_get_custom_code, +}; const struct aml_remote_reg_proto *remote_reg_proto[] = { ®_nec, @@ -509,6 +565,7 @@ const struct aml_remote_reg_proto *remote_reg_proto[] = { ®_rc5, ®_rc6, ®_legacy_nec, + ®_toshiba, NULL }; diff --git a/include/dt-bindings/input/meson_rc.h b/include/dt-bindings/input/meson_rc.h index c572dba2bb39..f01d5b7456c6 100644 --- a/include/dt-bindings/input/meson_rc.h +++ b/include/dt-bindings/input/meson_rc.h @@ -21,6 +21,7 @@ #define REMOTE_TYPE_XMP_1 0x03 #define REMOTE_TYPE_RC5 0x04 #define REMOTE_TYPE_RC6 0x05 +#define REMOTE_TYPE_TOSHIBA 0x06 /*hardware decode one protocol by using legacy IR controller*/ #define REMOTE_TYPE_LEGACY_NEC 0xff @@ -39,5 +40,7 @@ *2. multi-format IR controller decode other protocol */ #define REMOTE_TYPE_NEC_RC6 ((REMOTE_TYPE_LEGACY_NEC << 8) | REMOTE_TYPE_RC6) +#define REMOTE_TYPE_NEC_TOSHIBA ((REMOTE_TYPE_LEGACY_NEC << 8) | \ + REMOTE_TYPE_TOSHIBA) #endif