Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 3393d53

Browse files
hhan11-intelzhenmingx
authored andcommitted
Enable Button LED of Redhookbay in Kernel 3.10
Enable Button LED of Redhookbay in Kernel 3.10 Note for EDISON: this could be re-used as a generic PWM driver. Signed-off-by: Han, He <he.han@intel.com>
1 parent 7c1d5bb commit 3393d53

5 files changed

Lines changed: 182 additions & 1 deletion

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef __INTEL_MID_PWM_H__
2+
#define __INTEL_MID_PWM_H__
3+
4+
#define MAX_DUTYCYCLE_PERCENTAGE 100
5+
6+
enum {
7+
PWM_LED = 0,
8+
PWM_VIBRATOR,
9+
PWM_LCD_BACKLIGHT,
10+
PWM_NUM,
11+
};
12+
13+
struct intel_mid_pwm_device_data {
14+
u16 reg_clkdiv0;
15+
u16 reg_clkdiv1;
16+
u16 reg_dutycyc;
17+
u8 val_clkdiv0;
18+
u8 val_clkdiv1;
19+
};
20+
21+
struct intel_mid_pwm_platform_data {
22+
int pwm_num;
23+
struct intel_mid_pwm_device_data *ddata;
24+
u16 reg_clksel;
25+
u8 val_clksel;
26+
};
27+
28+
int intel_mid_pwm(int id, int value);
29+
#endif
30+

arch/x86/platform/intel-mid/device_libs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ obj-y += pci/
1414
obj-$(subst m,y,$(CONFIG_BATTERY_INTEL_MDF)) += platform_msic_battery.o
1515
obj-$(subst m,y,$(CONFIG_INTEL_MID_POWER_BUTTON)) += platform_msic_power_btn.o
1616
obj-$(subst m,y,$(CONFIG_GPIO_INTEL_PMIC)) += platform_pmic_gpio.o
17+
obj-$(subst m,y,$(CONFIG_MID_PWM)) += platform_mid_pwm.o
1718
obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o
1819
obj-$(subst m,y,$(CONFIG_SENSORS_MID_VDD)) += platform_msic_vdd.o
1920
obj-$(subst m,y,$(CONFIG_SENSORS_MRFL_OCD)) += platform_mrfl_ocd.o
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* platform_mid_pwm.c: mid_pwm platform data initilization file
3+
*
4+
* (C) Copyright 2008 Intel Corporation
5+
* Author:
6+
*
7+
* This program is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU General Public License
9+
* as published by the Free Software Foundation; version 2
10+
* of the License.
11+
*/
12+
13+
#include <linux/input.h>
14+
#include <linux/init.h>
15+
#include <linux/kernel.h>
16+
#include <linux/gpio.h>
17+
#include <linux/platform_device.h>
18+
#include <linux/lnw_gpio.h>
19+
20+
#include <asm/intel-mid.h>
21+
#include <asm/intel_mid_pwm.h>
22+
#include <asm/intel_mid_remoteproc.h>
23+
24+
#include "platform_mid_pwm.h"
25+
26+
static struct intel_mid_pwm_device_data mfld_pwms[] = {
27+
[PWM_LED] = {
28+
.reg_clkdiv0 = 0x62,
29+
.reg_clkdiv1 = 0x61,
30+
.reg_dutycyc = 0x67,
31+
.val_clkdiv1 = 0x00,
32+
.val_clkdiv0 = 0x03,
33+
},
34+
[PWM_VIBRATOR] = {
35+
.reg_clkdiv0 = 0x64,
36+
.reg_clkdiv1 = 0x63,
37+
.reg_dutycyc = 0x68,
38+
.val_clkdiv1 = 0x00,
39+
.val_clkdiv0 = 0x03,
40+
},
41+
[PWM_LCD_BACKLIGHT] = {
42+
.reg_clkdiv0 = 0x66,
43+
.reg_clkdiv1 = 0x65,
44+
.reg_dutycyc = 0x69,
45+
.val_clkdiv1 = 0x00,
46+
.val_clkdiv0 = 0x03,
47+
},
48+
};
49+
50+
static struct intel_mid_pwm_device_data ctp_pwms[] = {
51+
[PWM_LED] = {
52+
.reg_clkdiv0 = 0x62,
53+
.reg_clkdiv1 = 0x61,
54+
.reg_dutycyc = 0x67,
55+
.val_clkdiv1 = 0x00,
56+
.val_clkdiv0 = 0x00,
57+
},
58+
[PWM_VIBRATOR] = {
59+
.reg_clkdiv0 = 0x64,
60+
.reg_clkdiv1 = 0x63,
61+
.reg_dutycyc = 0x68,
62+
.val_clkdiv1 = 0x00,
63+
.val_clkdiv0 = 0x03,
64+
},
65+
[PWM_LCD_BACKLIGHT] = {
66+
.reg_clkdiv0 = 0x66,
67+
.reg_clkdiv1 = 0x65,
68+
.reg_dutycyc = 0x69,
69+
.val_clkdiv1 = 0x00,
70+
.val_clkdiv0 = 0x03,
71+
},
72+
};
73+
74+
static struct intel_mid_pwm_platform_data pdata[] = {
75+
[mfld_pwm] = {
76+
.pwm_num = PWM_NUM,
77+
.ddata = mfld_pwms,
78+
.reg_clksel = 0x38F,
79+
.val_clksel = 0x01,
80+
},
81+
[ctp_pwm] = {
82+
.pwm_num = PWM_NUM,
83+
.ddata = ctp_pwms,
84+
.reg_clksel = 0x38F,
85+
.val_clksel = 0x00,
86+
},
87+
};
88+
89+
static void *get_pwm_platform_data(void)
90+
{
91+
if (INTEL_MID_BOARD(1, PHONE, CLVTP) ||
92+
(INTEL_MID_BOARD(1, TABLET, CLVT))) {
93+
pr_info("%s, CLV board detected\n", __func__);
94+
return &pdata[ctp_pwm];
95+
} else {
96+
pr_info("%s, MFLD board detected\n", __func__);
97+
return &pdata[mfld_pwm];
98+
}
99+
}
100+
101+
static int __init intel_mid_pwm_init(void)
102+
{
103+
struct platform_device *pdev = NULL;
104+
int ret = 0;
105+
106+
pdev = platform_device_alloc(DEVICE_NAME, -1);
107+
108+
if (!pdev) {
109+
pr_err("out of memory for platform dev %s\n",
110+
DEVICE_NAME);
111+
return -1;
112+
}
113+
114+
pdev->dev.platform_data = get_pwm_platform_data();
115+
116+
ret = platform_device_add(pdev);
117+
if (ret) {
118+
pr_err("failed to add platform device %s\n",
119+
DEVICE_NAME);
120+
platform_device_put(pdev);
121+
return -1;
122+
}
123+
124+
return 0;
125+
}
126+
127+
fs_initcall(intel_mid_pwm_init);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* platform_mid_pwm.h: mid_pwm platform data header file
3+
*
4+
* (C) Copyright 2008 Intel Corporation
5+
* Author:
6+
*
7+
* This program is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU General Public License
9+
* as published by the Free Software Foundation; version 2
10+
* of the License.
11+
*/
12+
#ifndef _PLATFORM_MID_PWM_H_
13+
#define _PLATFORM_MID_PWM_H_
14+
15+
#define DEVICE_NAME "intel_mid_pwm"
16+
17+
enum {
18+
mfld_pwm,
19+
ctp_pwm,
20+
};
21+
#endif

arch/x86/platform/intel-mid/intel_mid_scu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ int intel_mid_rproc_init(void)
7979
register_rpmsg_service("rpmsg_kpd_led", RPROC_SCU,
8080
RP_MSIC_KPD_LED);
8181
register_rpmsg_service("rpmsg_modem_nvram", RPROC_SCU,
82-
RP_IPC_SIMPLE_COMMAND);
82+
RP_IPC_RAW_COMMAND);
83+
register_rpmsg_service("rpmsg_mid_pwm", RPROC_SCU,
84+
RP_MSIC_PWM);
8385

8486
err = platform_device_register(&intel_scu_device);
8587
if (err < 0)

0 commit comments

Comments
 (0)