drivers/mfd: remove unused ricoh619 driver

Change-Id: I8e2be84e4356399b32816b829c5e07614717f848
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
This commit is contained in:
Tao Huang
2018-11-03 13:37:26 +08:00
parent b312989886
commit 495446cde6
12 changed files with 0 additions and 9627 deletions

View File

@@ -1,229 +0,0 @@
ricoh619 Power Management Integrated Circuit
Required properties:
- compatible: "rockchip,ricoh619"
- reg: I2C slave address
- gpios: the interrupt pin\ sleep pin \dc_dec pin
use gpio get IRQ number
get adp plug in or out
- regulators: This is the list of child nodes that specify the regulator
initialization data for defined regulators. Not all regulators for the given
device need to be present. The definition for each of these nodes is defined
using the standard binding for regulators found at
Documentation/devicetree/bindings/regulator/regulator.txt.
The regulator is matched with the regulator-compatible.
The valid regulator-compatible values are:
ricoh619: ricoh619_dc1, ricoh619_dc2, ricoh619_dc3, ricoh619_dc4, ricoh619_dc5,ricoh619_ldo1, ricoh619_ldo2, ricoh619_ldo3, ricoh619_ldo4, ricoh619_ldo5, ricoh619_ldo6,
ricoh619_ldo7, ricoh619_ldo8,ricoh619_ldo9,ricoh619_ldo10,ricoh619_ldortc1,ricoh619_ldortc2
Optional properties:
- gpios:
gpios 0 :irq pin gpio
gpios 1 :sleep pin gpio
gpios 2 :dc det pin
- regulator-initial-mode: default mode to set on startup
- regulator-initial-state: suspend state to set at init
- regulator-state-mem, regulator-state-disk, regulator-state-standby:
defines regulator suspend to memory, suspend to disk (hibernate) and standby respectively.
have following sub-constarints:
- regulator-state-uv: suspend voltage
- regulator-state-mode: suspend regulator operating mode
- regulator-state-enabled: is regulator enabled in this suspend state
- regulator-state-disabled: is the regulator disbled in this suspend state
-regulator-initial-mode and regulator-state-mode is set as:
REGULATOR_MODE_FAST 0x1
REGULATOR_MODE_NORMAL 0x2
REGULATOR_MODE_IDLE 0x4
REGULATOR_MODE_STANDBY 0x8
Example:
ricoh619: ricoh619@32 {
reg = <0x32>;
status = "okay";
};
gpios =<&gpio0 GPIO_A4 GPIO_ACTIVE_HIGH>,<&gpio0 GPIO_B3 GPIO_ACTIVE_LOW>,<&gpio0 GPIO_B0 GPIO_ACTIVE_HIGH>;
ricoh619,system-power-controller; //support power off
&ricoh619 {
compatible = "ricoh,ricoh619";
regulators {
#address-cells = <1>;
#size-cells = <0>;
regulators {
ricoh619_dcdc1_reg: regulator@0 {
regulator-name = "vdd_logic";
regulator-min-microvolt = < 700000>;
regulator-max-microvolt = <1500000>;
regulator-initial-mode = <0x2>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-mode = <0x2>;
regulator-state-enabled;
regulator-state-uv = <900000>;
};
};
ricoh619_dcdc2_reg: regulator@1 {
regulator-name = "ricoh619_dcdc2";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
regulator-initial-mode = <0x2>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-mode = <0x2>;
regulator-state-enabled;
regulator-state-uv = <1200000>;
};
};
ricoh619_dcdc3_reg: regulator@2 {
regulator-name = "ricoh619_dcdc3";
regulator-min-microvolt = < 1200000>;
regulator-max-microvolt = <1200000>;
regulator-initial-mode = <0x2>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-mode = <0x2>;
regulator-state-enabled;
regulator-state-uv = <1200000>;
};
};
ricoh619_dcdc4_reg: regulator@3 {
regulator-name = "ricoh619_dcdc4";
regulator-min-microvolt = < 3300000>;
regulator-max-microvolt = <3300000>;
regulator-initial-mode = <0x2>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-mode = <0x2>;
regulator-state-enabled;
regulator-state-uv = <2800000>;
};
};
ricoh619_dcdc5_reg: regulator@4 {
regulator-name = "ricoh619_dcdc5";
regulator-min-microvolt = < 2000000>;
regulator-max-microvolt = <2000000>;
regulator-initial-mode = <0x2>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-mode = <0x2>;
regulator-state-enabled;
regulator-state-uv = <2000000>;
};
};
ricoh619_ldo1_reg: regulator@5 {
regulator-name = "ricoh619_ldo1";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldo2_reg: regulator@6 {
regulator-name = "ricoh619_ldo2";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldo3_reg: regulator@7 {
regulator-name = "ricoh619_ldo3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldo4_reg: regulator@8 {
regulator-name = "vcc_sd";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldo5_reg: regulator@9 {
regulator-name = "ricoh619_ldo5";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldo6_reg: regulator@10 {
regulator-name = "ricoh619_ldo6";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <1800000>;
};
};
ricoh619_ldo7_reg: regulator@11 {
regulator-name = "ricoh619_ldo7";
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1000000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldo8_reg: regulator@12 {
regulator-name = "ricoh619_ldo8";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldo9_reg: regulator@13 {
regulator-name = "ricoh619_ldo9";
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1000000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldo10_reg: regulator@14 {
regulator-name = "ricoh619_ldo10";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-initial-state = <3>;
regulator-state-mem {
regulator-state-enabled;
regulator-state-uv = <3300000>;
};
};
ricoh619_ldortc1_reg: regulator@15 {
regulator-name = "ricoh619_ldortc1";
regulator-min-microvolt = < 3300000>;
regulator-max-microvolt = <3300000>;
};
ricoh619_ldortc2_reg: regulator@16 {
regulator-name = "ricoh619_ldortc2";
regulator-min-microvolt = < 3300000>;
regulator-max-microvolt = <3300000>;
};
};
};

View File

@@ -1,169 +0,0 @@
/*
* Copyright (C) 2014 Ricoh Electronic Devices Co., Ltd. - http://www.rioch.com/LSI
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/*
* Integrated Power Management Chip
* http://www.ricoh.com/LSI/product_pmic/multiple-pmu/rc5t619/
*/
&ricoh619
{
compatible = "ricoh,ricoh619";
interrupt-controller;
#interrupt-cells = <0>;
pwrkey: pwrkey@0 {
compatible = "ricoh,ricoh619-pwrkey";
ricoh,pwrkey-delay-ms = <20>;
};
rtc {
compatible = "ricoh,ricoh619-rtc";
ricoh,rtc-tm-year = <2014>;
ricoh,rtc-tm-month = <1>;
ricoh,rtc-tm-mday = <1>;
ricoh,rtc-tm-hour = <8>;
ricoh,rtc-tm-min = <0>;
ricoh,rtc-tm-sec = <0>;
};
battery {
compatible = "ricoh,ricoh619-battery";
ricoh,alarm-vol-mv = <3300>;
ricoh,multiple = <100>;
ricoh,monitor-time = <1>;
ricoh,ch-vfchg = <0xff>;/* VFCHG = 0 - 4 (4.05v, 4.10v, 4.15v, 4.20v, 4.35v) */
ricoh,ch-vrchg = <0xff>;/* VRCHG = 0 - 4 (3.85v, 3.90v, 3.95v, 4.00v, 4.10v) */
ricoh,ch-vbatovset = <0xff>;/* VBATOVSET = 0 or 1 (0 : 4.38v(up)/3.95v(down) 1: 4.53v(up)/4.10v(down)) */
ricoh,ch-ichg = <0xff>;/* ICHG = 0 - 0x1D (100mA - 3000mA) */
ricoh,ch-ilim-adp = <0xff>;/* ILIM_ADP = 0 - 0x1D (100mA - 3000mA) */
ricoh,ch-ilim-usb = <0xff>;/* ILIM_USB = 0 - 0x1D (100mA - 3000mA) */
ricoh,ch-icchg = <0x03>;/* ICCHG = 0 - 3 (50mA 100mA 150mA 200mA) */
ricoh,fg-target-vsys = <3000>;/* This value is the target one to DSOC=0% */
ricoh,fg-target-ibat = <1000>;/* This value is the target one to DSOC=0% */
ricoh,fg-poff-vbat = <0>;/* setting value of 0 per Vbat */
ricoh,jt-en = <0>;/* JEITA Enable = 0 or 1 (1:enable, 0:disable) */
ricoh,jt-hw-sw = <1>;/* JEITA HW or SW = 0 or 1 (1:HardWare, 0:SoftWare) */
ricoh,jt-temp-h = <50>;/* degree C */
ricoh,jt-temp-l = <12>;/* degree C */
ricoh,jt-vfchg-h = <0x03>;/* VFCHG High = 0 - 4 (4.05v, 4.10v, 4.15v, 4.20v, 4.35v) */
ricoh,jt-vfchg-l = <0>;/* VFCHG High = 0 - 4 (4.05v, 4.10v, 4.15v, 4.20v, 4.35v) */
ricoh,jt-ichg-h = <0x0D>;/* VFCHG Low = 0 - 4 (4.05v, 4.10v, 4.15v, 4.20v, 4.35v) */
ricoh,jt-ichg-l = <0x09>;/* ICHG Low = 0 - 0x1D (100mA - 3000mA) */
};
regulators {
#address-cells = <1>;
#size-cells = <0>;
ricoh619_dcdc1_reg: regulator@0 {
reg = <0>;
regulator-compatible = "ricoh619_dc1";
regulator-always-on;
regulator-boot-on;
};
ricoh619_dcdc2_reg: regulator@1 {
reg = <1>;
regulator-compatible = "ricoh619_dc2";
regulator-always-on;
regulator-boot-on;
};
ricoh619_dcdc3_reg: regulator@2 {
reg = <2>;
regulator-compatible = "ricoh619_dc3";
regulator-always-on;
regulator-boot-on;
};
ricoh619_dcdc4_reg: regulator@3 {
reg = <3>;
regulator-compatible = "ricoh619_dc4";
regulator-always-on;
regulator-boot-on;
};
ricoh619_dcdc5_reg: regulator@4 {
reg = <4>;
regulator-compatible = "ricoh619_dc5";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo1_reg: regulator@5 {
reg = <5>;
regulator-compatible = "ricoh619_ldo1";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo2_reg: regulator@6 {
reg = <6>;
regulator-compatible = "ricoh619_ldo2";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo3_reg: regulator@7 {
reg = <7>;
regulator-compatible = "ricoh619_ldo3";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo4_reg: regulator@8 {
reg = <8>;
regulator-compatible = "ricoh619_ldo4";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo5_reg: regulator@9 {
reg = <9>;
regulator-compatible = "ricoh619_ldo5";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo6_reg: regulator@10 {
reg = <10>;
regulator-compatible = "ricoh619_ldo6";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo7_reg: regulator@11 {
reg = <11>;
regulator-compatible = "ricoh619_ldo7";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo8_reg: regulator@12 {
reg = <12>;
regulator-compatible = "ricoh619_ldo8";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo9_reg: regulator@13 {
reg = <13>;
regulator-compatible = "ricoh619_ldo9";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldo10_reg: regulator@14 {
reg = <14>;
regulator-compatible = "ricoh619_ldo10";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldortc1_reg: regulator@15 {
reg = <15>;
regulator-compatible = "ricoh619_ldortc1";
regulator-always-on;
regulator-boot-on;
};
ricoh619_ldortc2_reg: regulator@16 {
reg = <16>;
regulator-compatible = "ricoh619_ldortc2";
regulator-always-on;
regulator-boot-on;
};
};
};

View File

@@ -1,382 +0,0 @@
/*
* driver/input/misc/ricoh619-pwrkey.c
*
* Power Key driver for RICOH RC5T619 power management chip.
*
* Copyright (C) 2012-2013 RICOH COMPANY,LTD
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/mfd/ricoh619.h>
#include <linux/spinlock.h>
#include <linux/timer.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/workqueue.h>
#include <linux/gpio.h>
#include <linux/of.h>
#include <linux/delay.h>
#include <linux/mfd/ricoh619.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#define RICOH619_ONKEY_TRIGGER_LEVEL 0
#define RICOH619_ONKEY_OFF_IRQ 0
struct ricoh619_pwrkey {
struct device *dev;
struct input_dev *pwr;
#if RICOH619_ONKEY_TRIGGER_LEVEL
struct timer_list timer;
#endif
struct workqueue_struct *workqueue;
struct work_struct work;
unsigned long delay;
int key_irq;
bool pressed_first;
struct ricoh619_pwrkey_platform_data *pdata;
spinlock_t lock;
};
struct ricoh619_pwrkey *g_pwrkey;
#if RICOH619_ONKEY_TRIGGER_LEVEL
void ricoh619_pwrkey_timer(unsigned long t)
{
queue_work(g_pwrkey->workqueue, &g_pwrkey->work);
}
#endif
extern u8 ricoh619_pwr_key_reg;
static void ricoh619_irq_work(struct work_struct *work)
{
/* unsigned long flags; */
uint8_t val;
int i=0;
// printk("PMU: %s: \n",__func__);
//spin_lock_irqsave(&g_pwrkey->lock, flags);
if((ricoh619_pwr_key_reg & 0x01) && ricoh619_pwrkey_wakeup){
printk("PMU: %s: pwrkey_wakeup\n",__func__);
ricoh619_pwrkey_wakeup = 0;
input_event(g_pwrkey->pwr, EV_KEY, KEY_POWER, 1);
input_event(g_pwrkey->pwr, EV_SYN, 0, 0);
input_event(g_pwrkey->pwr, EV_KEY, KEY_POWER, 0);
input_event(g_pwrkey->pwr, EV_SYN, 0, 0);
do{
ricoh619_read(g_pwrkey->dev->parent, RICOH619_INT_MON_SYS, &val);
val &= 0x01;
i += 1;
msleep(100);
}while(val && (i < 15));
return;
}
ricoh619_read(g_pwrkey->dev->parent, RICOH619_INT_MON_SYS, &val);
dev_dbg(g_pwrkey->dev, "pwrkey is pressed?(0x%x): 0x%x\n",
RICOH619_INT_MON_SYS, val);
// printk(KERN_INFO "PMU: %s: val=0x%x\n", __func__, val);
val &= 0x1;
if(val){
#if (RICOH619_ONKEY_TRIGGER_LEVEL)
g_pwrkey->timer.expires = jiffies + g_pwrkey->delay;
add_timer(&g_pwrkey->timer);
#endif
if (!g_pwrkey->pressed_first){
g_pwrkey->pressed_first = true;
// printk("PMU1: %s: Power Key!!!\n",__func__);
//input_report_key(g_pwrkey->pwr, KEY_POWER, 1);
//input_sync(g_pwrkey->pwr);
input_event(g_pwrkey->pwr, EV_KEY, KEY_POWER, 1);
input_event(g_pwrkey->pwr, EV_SYN, 0, 0);
}
} else {
if (g_pwrkey->pressed_first) {
// printk(KERN_INFO "PMU2: %s: Power Key!!!\n", __func__);
/* input_report_key(g_pwrkey->pwr, KEY_POWER, 0); */
/* input_sync(g_pwrkey->pwr); */
input_event(g_pwrkey->pwr, EV_KEY, KEY_POWER, 0);
input_event(g_pwrkey->pwr, EV_SYN, 0, 0);
}
g_pwrkey->pressed_first = false;
}
/* spin_unlock_irqrestore(&g_pwrkey->lock, flags); */
}
static irqreturn_t pwrkey_irq(int irq, void *_pwrkey)
{
// printk(KERN_INFO "PMU: %s:\n", __func__);
// rk_send_wakeup_key();
#if (RICOH619_ONKEY_TRIGGER_LEVEL)
g_pwrkey->timer.expires = jiffies + g_pwrkey->delay;
add_timer(&g_pwrkey->timer);
#else
queue_work(g_pwrkey->workqueue, &g_pwrkey->work);
#endif
return IRQ_HANDLED;
}
#if RICOH619_ONKEY_OFF_IRQ
static irqreturn_t pwrkey_irq_off(int irq, void *_pwrkey)
{
dev_warn(g_pwrkey->dev, "ONKEY is pressed long time!\n");
return IRQ_HANDLED;
}
#endif
#ifdef CONFIG_OF
static struct ricoh619_pwrkey_platform_data *
ricoh619_pwrkey_dt_init(struct platform_device *pdev)
{
struct device_node *nproot = pdev->dev.parent->of_node;
struct device_node *np;
struct ricoh619_pwrkey_platform_data *pdata;
if (!nproot)
return pdev->dev.platform_data;
np = of_find_node_by_name(nproot, "pwrkey");
if (!np) {
dev_err(&pdev->dev, "failed to find pwrkey node\n");
return NULL;
}
pdata = devm_kzalloc(&pdev->dev,
sizeof(struct ricoh619_pwrkey_platform_data),
GFP_KERNEL);
of_property_read_u32(np, "ricoh,pwrkey-delay-ms", &pdata->delay_ms);
of_node_put(np);
return pdata;
}
#else
static struct ricoh619_pwrkey_platform_data *
ricoh619_pwrkey_dt_init(struct platform_device *pdev)
{
return pdev->dev.platform_data;
}
#endif
static int ricoh619_pwrkey_probe(struct platform_device *pdev)
{
struct input_dev *pwr;
int key_irq;
int err;
struct ricoh619_pwrkey *pwrkey;
struct ricoh619_pwrkey_platform_data *pdata;
struct ricoh619 *ricoh619 = dev_get_drvdata(pdev->dev.parent);
uint8_t val;
// printk("PMU: %s: \n",__func__);
pdata = ricoh619_pwrkey_dt_init(pdev);
if (!pdata) {
dev_err(&pdev->dev, "platform data isn't assigned to "
"power key\n");
return -EINVAL;
}
key_irq = irq_create_mapping(ricoh619->irq_domain, RICOH619_IRQ_POWER_ON);
printk(KERN_INFO "PMU1: %s: key_irq=%d\n", __func__, key_irq);
pwrkey = kzalloc(sizeof(*pwrkey), GFP_KERNEL);
if (!pwrkey)
return -ENOMEM;
pwrkey->dev = &pdev->dev;
pwrkey->pdata = pdata;
pwrkey->pressed_first = false;
pwrkey->delay = HZ / 1000 * pdata->delay_ms;
g_pwrkey = pwrkey;
pwr = input_allocate_device();
if (!pwr) {
dev_dbg(&pdev->dev, "Can't allocate power button\n");
err = -ENOMEM;
goto free_pwrkey;
}
input_set_capability(pwr, EV_KEY, KEY_POWER);
pwr->name = "ricoh619_pwrkey";
pwr->phys = "ricoh619_pwrkey/input0";
pwr->dev.parent = &pdev->dev;
#if RICOH619_ONKEY_TRIGGER_LEVEL
init_timer(&pwrkey->timer);
pwrkey->timer.function = ricoh619_pwrkey_timer;
#endif
spin_lock_init(&pwrkey->lock);
err = input_register_device(pwr);
if (err) {
dev_dbg(&pdev->dev, "Can't register power key: %d\n", err);
goto free_input_dev;
}
pwrkey->key_irq = key_irq;
pwrkey->pwr = pwr;
platform_set_drvdata(pdev, pwrkey);
/* Check if power-key is pressed at boot up */
err = ricoh619_read(pwrkey->dev->parent, RICOH619_INT_MON_SYS, &val);
if (err < 0) {
dev_err(&pdev->dev, "Key-press status at boot failed rc=%d\n",
err);
goto unreg_input_dev;
}
val &= 0x1;
if (val) {
input_report_key(pwrkey->pwr, KEY_POWER, 1);
// printk(KERN_INFO "******KEY_POWER:1\n");
input_sync(pwrkey->pwr);
pwrkey->pressed_first = true;
}
#if !(RICOH619_ONKEY_TRIGGER_LEVEL)
/* trigger both edge */
ricoh619_set_bits(pwrkey->dev->parent, RICOH619_PWR_IRSEL, 0x1);
#endif
err = request_threaded_irq(key_irq, NULL, pwrkey_irq,IRQF_ONESHOT, "ricoh619_pwrkey", pwrkey);
if (err < 0) {
dev_err(&pdev->dev, "Can't get %d IRQ for pwrkey: %d\n",
key_irq, err);
goto unreg_input_dev;
}
/*
#if RICOH619_ONKEY_OFF_IRQ
err = request_threaded_irq( key_irq +RICOH619_ONKEY_OFF_IRQ, NULL,pwrkey_irq_off, IRQF_ONESHOT,
"ricoh619_pwrkey_off", pwrkey);
if (err < 0) {
dev_err(&pdev->dev, "Can't get %d IRQ for ricoh619_pwrkey_off: %d\n",
key_irq + RICOH619_ONKEY_OFF_IRQ, err);
free_irq(key_irq, pwrkey);
goto unreg_input_dev;
}
#endif
*/
pwrkey->workqueue = create_singlethread_workqueue("ricoh619_pwrkey");
INIT_WORK(&pwrkey->work, ricoh619_irq_work);
/* Enable power key IRQ */
/* trigger both edge */
ricoh619_set_bits(pwrkey->dev->parent, RICOH619_PWR_IRSEL, 0x1);
/* Enable system interrupt */
ricoh619_set_bits(pwrkey->dev->parent, RICOH619_INTC_INTEN, 0x1);
/* Enable power-on interrupt */
ricoh619_set_bits(pwrkey->dev->parent, RICOH619_INT_EN_SYS, 0x1);
// printk(KERN_INFO "PMU: %s is OK!\n", __func__);
return 0;
unreg_input_dev:
input_unregister_device(pwr);
pwr = NULL;
free_input_dev:
input_free_device(pwr);
free_pwrkey:
kfree(pwrkey);
return err;
}
static int ricoh619_pwrkey_remove(struct platform_device *pdev)
{
struct ricoh619_pwrkey *pwrkey = platform_get_drvdata(pdev);
flush_workqueue(pwrkey->workqueue);
destroy_workqueue(pwrkey->workqueue);
free_irq(pwrkey->key_irq, pwrkey);
input_unregister_device(pwrkey->pwr);
kfree(pwrkey);
return 0;
}
#ifdef CONFIG_PM
static int ricoh619_pwrkey_suspend(struct device *dev)
{
struct ricoh619_pwrkey *info = dev_get_drvdata(dev);
// printk(KERN_INFO "PMU: %s\n", __func__);
// if (info->key_irq)
// disable_irq(info->key_irq);
cancel_work_sync(&info->work);
flush_workqueue(info->workqueue);
return 0;
}
static int ricoh619_pwrkey_resume(struct device *dev)
{
struct ricoh619_pwrkey *info = dev_get_drvdata(dev);
// printk(KERN_INFO "PMU: %s\n", __func__);
queue_work(info->workqueue, &info->work);
// if (info->key_irq)
// enable_irq(info->key_irq);
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id ricoh619_pwrkey_dt_match[] = {
{ .compatible = "ricoh,ricoh619-pwrkey", },
{},
};
MODULE_DEVICE_TABLE(of, ricoh619_pwrkey_dt_match);
#endif
static const struct dev_pm_ops ricoh619_pwrkey_pm_ops = {
.suspend = ricoh619_pwrkey_suspend,
.resume = ricoh619_pwrkey_resume,
};
#endif
static struct platform_driver ricoh619_pwrkey_driver = {
.probe = ricoh619_pwrkey_probe,
.remove = ricoh619_pwrkey_remove,
.driver = {
.name = "ricoh619-pwrkey",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(ricoh619_pwrkey_dt_match),
#ifdef CONFIG_PM
.pm = &ricoh619_pwrkey_pm_ops,
#endif
},
};
static int __init ricoh619_pwrkey_init(void)
{
return platform_driver_register(&ricoh619_pwrkey_driver);
}
subsys_initcall_sync(ricoh619_pwrkey_init);
static void __exit ricoh619_pwrkey_exit(void)
{
platform_driver_unregister(&ricoh619_pwrkey_driver);
}
module_exit(ricoh619_pwrkey_exit);
MODULE_ALIAS("platform:ricoh619-pwrkey");
MODULE_AUTHOR("zhangqing <zhangqing@rock-chips.com>");
MODULE_DESCRIPTION("ricoh619 Power Key");
MODULE_LICENSE("GPL v2");

View File

@@ -1,618 +0,0 @@
/*
* driver/mfd/ricoh619-irq.c
*
* Interrupt driver for RICOH RC5T619 power management chip.
*
* Copyright (C) 2012-2013 RICOH COMPANY,LTD
*
* Based on code
* Copyright (C) 2011 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/mfd/ricoh619.h>
#include <linux/irqdomain.h>
static DEFINE_MUTEX(int_flag_mutex);
enum int_type {
SYS_INT = 0x1,
DCDC_INT = 0x2,
RTC_INT = 0x4,
ADC_INT = 0x8,
GPIO_INT = 0x10,
CHG_INT = 0x40,
};
static int gpedge_add[] = {
RICOH619_GPIO_GPEDGE1,
RICOH619_GPIO_GPEDGE2
};
static int irq_en_add[] = {
RICOH619_INT_EN_SYS,
RICOH619_INT_EN_DCDC,
RICOH619_INT_EN_RTC,
RICOH619_INT_EN_ADC1,
RICOH619_INT_EN_ADC2,
RICOH619_INT_EN_ADC3,
RICOH619_INT_EN_GPIO,
RICOH619_INT_EN_GPIO2,
RICOH619_INT_MSK_CHGCTR,
RICOH619_INT_MSK_CHGSTS1,
RICOH619_INT_MSK_CHGSTS2,
RICOH619_INT_MSK_CHGERR,
RICOH619_INT_MSK_CHGEXTIF
};
static int irq_mon_add[] = {
RICOH619_INT_IR_SYS, //RICOH619_INT_MON_SYS,
RICOH619_INT_IR_DCDC, //RICOH619_INT_MON_DCDC,
RICOH619_INT_IR_RTC, //RICOH619_INT_MON_RTC,
RICOH619_INT_IR_ADCL,
RICOH619_INT_IR_ADCH,
RICOH619_INT_IR_ADCEND,
RICOH619_INT_IR_GPIOR,
RICOH619_INT_IR_GPIOF,
RICOH619_INT_IR_CHGCTR, //RICOH619_INT_MON_CHGCTR,
RICOH619_INT_IR_CHGSTS1, //RICOH619_INT_MON_CHGSTS1,
RICOH619_INT_IR_CHGSTS2, //RICOH619_INT_MON_CHGSTS2,
RICOH619_INT_IR_CHGERR, //RICOH619_INT_MON_CHGERR
RICOH619_INT_IR_CHGEXTIF //RICOH619_INT_MON_CHGEXTIF
};
static int irq_clr_add[] = {
RICOH619_INT_IR_SYS,
RICOH619_INT_IR_DCDC,
RICOH619_INT_IR_RTC,
RICOH619_INT_IR_ADCL,
RICOH619_INT_IR_ADCH,
RICOH619_INT_IR_ADCEND,
RICOH619_INT_IR_GPIOR,
RICOH619_INT_IR_GPIOF,
RICOH619_INT_IR_CHGCTR,
RICOH619_INT_IR_CHGSTS1,
RICOH619_INT_IR_CHGSTS2,
RICOH619_INT_IR_CHGERR,
RICOH619_INT_IR_CHGEXTIF
};
static int main_int_type[] = {
SYS_INT,
DCDC_INT,
RTC_INT,
ADC_INT,
ADC_INT,
ADC_INT,
GPIO_INT,
GPIO_INT,
CHG_INT,
CHG_INT,
CHG_INT,
CHG_INT,
CHG_INT,
};
struct ricoh619_irq_data {
u8 int_type;
u8 master_bit;
u8 int_en_bit;
u8 mask_reg_index;
int grp_index;
};
#define RICOH619_IRQ(_int_type, _master_bit, _grp_index, _int_bit, _mask_ind) \
{ \
.int_type = _int_type, \
.master_bit = _master_bit, \
.grp_index = _grp_index, \
.int_en_bit = _int_bit, \
.mask_reg_index = _mask_ind, \
}
static const struct ricoh619_irq_data ricoh619_irqs[RICOH619_NR_IRQS] = {
[RICOH619_IRQ_POWER_ON] = RICOH619_IRQ(SYS_INT, 0, 0, 0, 0),
[RICOH619_IRQ_EXTIN] = RICOH619_IRQ(SYS_INT, 0, 1, 1, 0),
[RICOH619_IRQ_PRE_VINDT] = RICOH619_IRQ(SYS_INT, 0, 2, 2, 0),
[RICOH619_IRQ_PREOT] = RICOH619_IRQ(SYS_INT, 0, 3, 3, 0),
[RICOH619_IRQ_POWER_OFF] = RICOH619_IRQ(SYS_INT, 0, 4, 4, 0),
[RICOH619_IRQ_NOE_OFF] = RICOH619_IRQ(SYS_INT, 0, 5, 5, 0),
[RICOH619_IRQ_WD] = RICOH619_IRQ(SYS_INT, 0, 6, 6, 0),
[RICOH619_IRQ_DC1LIM] = RICOH619_IRQ(DCDC_INT, 1, 0, 0, 1),
[RICOH619_IRQ_DC2LIM] = RICOH619_IRQ(DCDC_INT, 1, 1, 1, 1),
[RICOH619_IRQ_DC3LIM] = RICOH619_IRQ(DCDC_INT, 1, 2, 2, 1),
[RICOH619_IRQ_DC4LIM] = RICOH619_IRQ(DCDC_INT, 1, 3, 3, 1),
[RICOH619_IRQ_DC5LIM] = RICOH619_IRQ(DCDC_INT, 1, 4, 4, 1),
[RICOH619_IRQ_CTC] = RICOH619_IRQ(RTC_INT, 2, 0, 0, 2),
[RICOH619_IRQ_DALE] = RICOH619_IRQ(RTC_INT, 2, 1, 6, 2),
[RICOH619_IRQ_ILIMLIR] = RICOH619_IRQ(ADC_INT, 3, 0, 0, 3),
[RICOH619_IRQ_VBATLIR] = RICOH619_IRQ(ADC_INT, 3, 1, 1, 3),
[RICOH619_IRQ_VADPLIR] = RICOH619_IRQ(ADC_INT, 3, 2, 2, 3),
[RICOH619_IRQ_VUSBLIR] = RICOH619_IRQ(ADC_INT, 3, 3, 3, 3),
[RICOH619_IRQ_VSYSLIR] = RICOH619_IRQ(ADC_INT, 3, 4, 4, 3),
[RICOH619_IRQ_VTHMLIR] = RICOH619_IRQ(ADC_INT, 3, 5, 5, 3),
[RICOH619_IRQ_AIN1LIR] = RICOH619_IRQ(ADC_INT, 3, 6, 6, 3),
[RICOH619_IRQ_AIN0LIR] = RICOH619_IRQ(ADC_INT, 3, 7, 7, 3),
[RICOH619_IRQ_ILIMHIR] = RICOH619_IRQ(ADC_INT, 3, 8, 0, 4),
[RICOH619_IRQ_VBATHIR] = RICOH619_IRQ(ADC_INT, 3, 9, 1, 4),
[RICOH619_IRQ_VADPHIR] = RICOH619_IRQ(ADC_INT, 3, 10, 2, 4),
[RICOH619_IRQ_VUSBHIR] = RICOH619_IRQ(ADC_INT, 3, 11, 3, 4),
[RICOH619_IRQ_VSYSHIR] = RICOH619_IRQ(ADC_INT, 3, 12, 4, 4),
[RICOH619_IRQ_VTHMHIR] = RICOH619_IRQ(ADC_INT, 3, 13, 5, 4),
[RICOH619_IRQ_AIN1HIR] = RICOH619_IRQ(ADC_INT, 3, 14, 6, 4),
[RICOH619_IRQ_AIN0HIR] = RICOH619_IRQ(ADC_INT, 3, 15, 7, 4),
[RICOH619_IRQ_ADC_ENDIR] = RICOH619_IRQ(ADC_INT, 3, 16, 0, 5),
[RICOH619_IRQ_GPIO0] = RICOH619_IRQ(GPIO_INT, 4, 0, 0, 6),
[RICOH619_IRQ_GPIO1] = RICOH619_IRQ(GPIO_INT, 4, 1, 1, 6),
[RICOH619_IRQ_GPIO2] = RICOH619_IRQ(GPIO_INT, 4, 2, 2, 6),
[RICOH619_IRQ_GPIO3] = RICOH619_IRQ(GPIO_INT, 4, 3, 3, 6),
[RICOH619_IRQ_GPIO4] = RICOH619_IRQ(GPIO_INT, 4, 4, 4, 6),
[RICOH619_IRQ_FVADPDETSINT] = RICOH619_IRQ(CHG_INT, 6, 0, 0, 8),
[RICOH619_IRQ_FVUSBDETSINT] = RICOH619_IRQ(CHG_INT, 6, 1, 1, 8),
[RICOH619_IRQ_FVADPLVSINT] = RICOH619_IRQ(CHG_INT, 6, 2, 2, 8),
[RICOH619_IRQ_FVUSBLVSINT] = RICOH619_IRQ(CHG_INT, 6, 3, 3, 8),
[RICOH619_IRQ_FWVADPSINT] = RICOH619_IRQ(CHG_INT, 6, 4, 4, 8),
[RICOH619_IRQ_FWVUSBSINT] = RICOH619_IRQ(CHG_INT, 6, 5, 5, 8),
[RICOH619_IRQ_FONCHGINT] = RICOH619_IRQ(CHG_INT, 6, 6, 0, 9),
[RICOH619_IRQ_FCHGCMPINT] = RICOH619_IRQ(CHG_INT, 6, 7, 1, 9),
[RICOH619_IRQ_FBATOPENINT] = RICOH619_IRQ(CHG_INT, 6, 8, 2, 9),
[RICOH619_IRQ_FSLPMODEINT] = RICOH619_IRQ(CHG_INT, 6, 9, 3, 9),
[RICOH619_IRQ_FBTEMPJTA1INT] = RICOH619_IRQ(CHG_INT, 6, 10, 4, 9),
[RICOH619_IRQ_FBTEMPJTA2INT] = RICOH619_IRQ(CHG_INT, 6, 11, 5, 9),
[RICOH619_IRQ_FBTEMPJTA3INT] = RICOH619_IRQ(CHG_INT, 6, 12, 6, 9),
[RICOH619_IRQ_FBTEMPJTA4INT] = RICOH619_IRQ(CHG_INT, 6, 13, 7, 9),
[RICOH619_IRQ_FCURTERMINT] = RICOH619_IRQ(CHG_INT, 6, 14, 0, 10),
[RICOH619_IRQ_FVOLTERMINT] = RICOH619_IRQ(CHG_INT, 6, 15, 1, 10),
[RICOH619_IRQ_FICRVSINT] = RICOH619_IRQ(CHG_INT, 6, 16, 2, 10),
[RICOH619_IRQ_FPOOR_CHGCURINT] = RICOH619_IRQ(CHG_INT, 6, 17, 3, 10),
[RICOH619_IRQ_FOSCFDETINT1] = RICOH619_IRQ(CHG_INT, 6, 18, 4, 10),
[RICOH619_IRQ_FOSCFDETINT2] = RICOH619_IRQ(CHG_INT, 6, 19, 5, 10),
[RICOH619_IRQ_FOSCFDETINT3] = RICOH619_IRQ(CHG_INT, 6, 20, 6, 10),
[RICOH619_IRQ_FOSCMDETINT] = RICOH619_IRQ(CHG_INT, 6, 21, 7, 10),
[RICOH619_IRQ_FDIEOFFINT] = RICOH619_IRQ(CHG_INT, 6, 22, 0, 11),
[RICOH619_IRQ_FDIEERRINT] = RICOH619_IRQ(CHG_INT, 6, 23, 1, 11),
[RICOH619_IRQ_FBTEMPERRINT] = RICOH619_IRQ(CHG_INT, 6, 24, 2, 11),
[RICOH619_IRQ_FVBATOVINT] = RICOH619_IRQ(CHG_INT, 6, 25, 3, 11),
[RICOH619_IRQ_FTTIMOVINT] = RICOH619_IRQ(CHG_INT, 6, 26, 4, 11),
[RICOH619_IRQ_FRTIMOVINT] = RICOH619_IRQ(CHG_INT, 6, 27, 5, 11),
[RICOH619_IRQ_FVADPOVSINT] = RICOH619_IRQ(CHG_INT, 6, 28, 6, 11),
[RICOH619_IRQ_FVUSBOVSINT] = RICOH619_IRQ(CHG_INT, 6, 29, 7, 11),
[RICOH619_IRQ_FGCDET] = RICOH619_IRQ(CHG_INT, 6, 30, 0, 12),
[RICOH619_IRQ_FPCDET] = RICOH619_IRQ(CHG_INT, 6, 31, 1, 12),
[RICOH619_IRQ_FWARN_ADP] = RICOH619_IRQ(CHG_INT, 6, 32, 3, 12),
};
static const inline struct ricoh619_irq_data * irq_to_ricoh619_irq(struct ricoh619 *ricoh619, int irq)
{
struct irq_data *data = irq_get_irq_data(irq);
return &ricoh619_irqs[data->hwirq];
}
static void ricoh619_irq_lock(struct irq_data *irq_data)
{
struct ricoh619 *ricoh619 = irq_data_get_irq_chip_data(irq_data);
mutex_lock(&ricoh619->irq_lock);
}
static void ricoh619_irq_unmask(struct irq_data *irq_data)
{
struct ricoh619 *ricoh619 = irq_data_get_irq_chip_data(irq_data);
const struct ricoh619_irq_data *data= irq_to_ricoh619_irq(ricoh619,irq_data->irq);
mutex_lock(&int_flag_mutex);
ricoh619->group_irq_en[data->master_bit] |= (1 << data->grp_index);
if (ricoh619->group_irq_en[data->master_bit])
ricoh619->intc_inten_reg |= 1 << data->master_bit;
if (data->master_bit == 6) /* if Charger */
ricoh619->irq_en_reg[data->mask_reg_index]
&= ~(1 << data->int_en_bit);
else
ricoh619->irq_en_reg[data->mask_reg_index]
|= 1 << data->int_en_bit;
mutex_unlock(&int_flag_mutex);
}
static void ricoh619_irq_mask(struct irq_data *irq_data)
{
struct ricoh619 *ricoh619 = irq_data_get_irq_chip_data(irq_data);
const struct ricoh619_irq_data *data= irq_to_ricoh619_irq(ricoh619,irq_data->irq);
mutex_lock(&int_flag_mutex);
ricoh619->group_irq_en[data->master_bit] &= ~(1 << data->grp_index);
if (!ricoh619->group_irq_en[data->master_bit])
ricoh619->intc_inten_reg &= ~(1 << data->master_bit);
if (data->master_bit == 6) /* if Charger */
ricoh619->irq_en_reg[data->mask_reg_index]
|= 1 << data->int_en_bit;
else
ricoh619->irq_en_reg[data->mask_reg_index]
&= ~(1 << data->int_en_bit);
mutex_unlock(&int_flag_mutex);
}
static void ricoh619_irq_sync_unlock(struct irq_data *irq_data)
{
struct ricoh619 *ricoh619 = irq_data_get_irq_chip_data(irq_data);
int i;
for (i = 0; i < ARRAY_SIZE(ricoh619->gpedge_reg); i++) {
if (ricoh619->gpedge_reg[i] != ricoh619->gpedge_cache[i]) {
if (!WARN_ON(ricoh619_write(ricoh619->dev, gpedge_add[i],ricoh619->gpedge_reg[i])))
ricoh619->gpedge_cache[i] =ricoh619->gpedge_reg[i];
}
}
for (i = 0; i < ARRAY_SIZE(ricoh619->irq_en_reg); i++) {
if (ricoh619->irq_en_reg[i] != ricoh619->irq_en_cache[i]) {
if (!WARN_ON(ricoh619_write(ricoh619->dev, irq_en_add[i],ricoh619->irq_en_reg[i])))
ricoh619->irq_en_cache[i] =ricoh619->irq_en_reg[i];
}
}
if (ricoh619->intc_inten_reg != ricoh619->intc_inten_cache) {
if (!WARN_ON(ricoh619_write(ricoh619->dev,RICOH619_INTC_INTEN, ricoh619->intc_inten_reg)))
ricoh619->intc_inten_cache = ricoh619->intc_inten_reg;
}
mutex_unlock(&ricoh619->irq_lock);
}
static int ricoh619_irq_set_type(struct irq_data *irq_data, unsigned int type)
{
struct ricoh619 *ricoh619 = irq_data_get_irq_chip_data(irq_data);
const struct ricoh619_irq_data *data= irq_to_ricoh619_irq(ricoh619,irq_data->irq);
int val = 0;
int gpedge_index;
int gpedge_bit_pos;
if (data->int_type & GPIO_INT) {
gpedge_index = data->int_en_bit / 4;
gpedge_bit_pos = data->int_en_bit % 4;
if (type & IRQ_TYPE_EDGE_FALLING)
val |= 0x2;
if (type & IRQ_TYPE_EDGE_RISING)
val |= 0x1;
ricoh619->gpedge_reg[gpedge_index] &= ~(3 << gpedge_bit_pos);
ricoh619->gpedge_reg[gpedge_index] |= (val << gpedge_bit_pos);
ricoh619_irq_unmask(irq_data);
}
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int ricoh619_irq_set_wake(struct irq_data *irq_data, unsigned int on)
{
struct ricoh619 *ricoh619 = irq_data_get_irq_chip_data(irq_data);
return irq_set_irq_wake(ricoh619->chip_irq, on); //i2c->irq
}
#else
#define ricoh619_irq_set_wake NULL
#endif
u8 ricoh619_pwr_key_reg;
static irqreturn_t ricoh619_irq(int irq, void *data)
{
struct ricoh619 *ricoh619 = data;
u8 int_sts[MAX_INTERRUPT_MASKS];
u8 master_int;
int i;
int ret;
unsigned int rtc_int_sts = 0;
int cur_irq = 0;
ret = ricoh619_read(ricoh619->dev, RICOH619_INT_IR_SYS, &ricoh619_pwr_key_reg);
/* Clear the status */
for (i = 0; i < MAX_INTERRUPT_MASKS; i++)
int_sts[i] = 0;
ret = ricoh619_read(ricoh619->dev, RICOH619_INTC_INTMON,
&master_int);
// printk("PMU1: %s: master_int=0x%x\n", __func__, master_int);
if (ret < 0) {
dev_err(ricoh619->dev, "Error in reading reg 0x%02x "
"error: %d\n", RICOH619_INTC_INTMON, ret);
return IRQ_HANDLED;
}
for (i = 0; i < MAX_INTERRUPT_MASKS; ++i) {
/* Even if INTC_INTMON register = 1, INT signal might not output
because INTC_INTMON register indicates only interrupt facter level.
So remove the following procedure */
if (!(master_int & main_int_type[i]))
continue;
ret = ricoh619_read(ricoh619->dev,
irq_mon_add[i], &int_sts[i]);
// printk("PMU2: %s: int_sts[%d]=0x%x\n", __func__,i, int_sts[i]);
if (ret < 0) {
dev_err(ricoh619->dev, "Error in reading reg 0x%02x "
"error: %d\n", irq_mon_add[i], ret);
int_sts[i] = 0;
continue;
}
if (!int_sts[i])
continue;
if (main_int_type[i] & RTC_INT) {
// Changes status bit position from RTCCNT2 to RTCCNT1
rtc_int_sts = 0;
if (int_sts[i] & 0x1)
rtc_int_sts |= BIT(6);
if (int_sts[i] & 0x4)
rtc_int_sts |= BIT(0);
}
if(irq_clr_add[i] == RICOH619_INT_IR_RTC)
{
int_sts[i] &= ~0x85;
ret = ricoh619_write(ricoh619->dev,
irq_clr_add[i], int_sts[i]);
if (ret < 0)
dev_err(ricoh619->dev, "Error in writing reg 0x%02x "
"error: %d\n", irq_clr_add[i], ret);
}
else
{
ret = ricoh619_write(ricoh619->dev,
irq_clr_add[i], ~int_sts[i]);
if (ret < 0)
dev_err(ricoh619->dev, "Error in reading reg 0x%02x "
"error: %d\n", irq_clr_add[i], ret);
}
/* Mask Charger Interrupt */
if (main_int_type[i] & CHG_INT) {
if (int_sts[i]) {
ret = ricoh619_write(ricoh619->dev,
irq_en_add[i], 0xff);
if (ret < 0) {
dev_err(ricoh619->dev,
"Error in write reg 0x%02x error: %d\n",
irq_en_add[i], ret);
}
}
}
/* Mask ADC Interrupt */
if (main_int_type[i] & ADC_INT) {
if (int_sts[i]) {
ret = ricoh619_write(ricoh619->dev,
irq_en_add[i], 0);
if (ret < 0) {
dev_err(ricoh619->dev,
"Error in write reg 0x%02x error: %d\n",
irq_en_add[i], ret);
}
}
}
if (main_int_type[i] & RTC_INT)
int_sts[i] = rtc_int_sts;
}
/* Merge gpio interrupts for rising and falling case*/
int_sts[6] |= int_sts[7];
/* Call interrupt handler if enabled */
mutex_lock(&int_flag_mutex);
for (i = 0; i <RICOH619_NR_IRQS; ++i) {
const struct ricoh619_irq_data *data = &ricoh619_irqs[i];
if ((int_sts[data->mask_reg_index] & (1 << data->int_en_bit)) &&(ricoh619->group_irq_en[data->master_bit] & (1 << data->grp_index))){
cur_irq = irq_find_mapping(ricoh619->irq_domain, i);
if (cur_irq)
handle_nested_irq(cur_irq);
}
}
mutex_unlock(&int_flag_mutex);
// printk(KERN_INFO "PMU: %s: out\n", __func__);
return IRQ_HANDLED;
}
static struct irq_chip ricoh619_irq_chip = {
.name = "ricoh619",
//.irq_mask = ricoh619_irq_mask,
//.irq_unmask = ricoh619_irq_unmask,
.irq_enable = ricoh619_irq_unmask,
.irq_disable = ricoh619_irq_mask,
.irq_bus_lock = ricoh619_irq_lock,
.irq_bus_sync_unlock = ricoh619_irq_sync_unlock,
.irq_set_type = ricoh619_irq_set_type,
.irq_set_wake = ricoh619_irq_set_wake,
};
static int ricoh619_irq_domain_map(struct irq_domain *d, unsigned int irq,
irq_hw_number_t hw)
{
struct ricoh619 *ricoh619 = d->host_data;
irq_set_chip_data(irq, ricoh619);
irq_set_chip_and_handler(irq, &ricoh619_irq_chip, handle_edge_irq);
irq_set_nested_thread(irq, 1);
#ifdef CONFIG_ARM
set_irq_flags(irq, IRQF_VALID);
#else
irq_set_noprobe(irq);
#endif
return 0;
}
static struct irq_domain_ops ricoh619_irq_domain_ops = {
.map = ricoh619_irq_domain_map,
};
int ricoh619_irq_init(struct ricoh619 *ricoh619, int irq,
struct ricoh619_platform_data *pdata)
{
int i, ret,val,irq_type,flags;
u8 reg_data = 0;
struct irq_domain *domain;
// printk("%s,line=%d\n", __func__,__LINE__);
if (!irq) {
dev_warn(ricoh619->dev, "No interrupt support, no core IRQ\n");
return 0;
}
mutex_init(&ricoh619->irq_lock);
/* Initialize all locals to 0 */
for (i = 0; i < 2; i++) {
ricoh619->irq_en_cache[i] = 0;
ricoh619->irq_en_reg[i] = 0;
}
/* Initialize rtc */
ricoh619->irq_en_cache[2] = 0x20;
ricoh619->irq_en_reg[2] = 0x20;
/* Initialize all locals to 0 */
for (i = 3; i < 8; i++) {
ricoh619->irq_en_cache[i] = 0;
ricoh619->irq_en_reg[i] = 0;
}
// Charger Mask register must be set to 1 for masking Int output.
for (i = 8; i < MAX_INTERRUPT_MASKS; i++) {
ricoh619->irq_en_cache[i] = 0xff;
ricoh619->irq_en_reg[i] = 0xff;
}
ricoh619->intc_inten_cache = 0;
ricoh619->intc_inten_reg = 0;
for (i = 0; i < MAX_GPEDGE_REG; i++) {
ricoh619->gpedge_cache[i] = 0;
ricoh619->gpedge_reg[i] = 0;
}
/* Initailize all int register to 0 */
for (i = 0; i < MAX_INTERRUPT_MASKS; i++) {
ret = ricoh619_write(ricoh619->dev,
irq_en_add[i],
ricoh619->irq_en_reg[i]);
if (ret < 0)
dev_err(ricoh619->dev, "Error in writing reg 0x%02x "
"error: %d\n", irq_en_add[i], ret);
}
for (i = 0; i < MAX_GPEDGE_REG; i++) {
ret = ricoh619_write(ricoh619->dev,
gpedge_add[i],
ricoh619->gpedge_reg[i]);
if (ret < 0)
dev_err(ricoh619->dev, "Error in writing reg 0x%02x "
"error: %d\n", gpedge_add[i], ret);
}
ret = ricoh619_write(ricoh619->dev, RICOH619_INTC_INTEN, 0x0);
if (ret < 0)
dev_err(ricoh619->dev, "Error in writing reg 0x%02x "
"error: %d\n", RICOH619_INTC_INTEN, ret);
/* Clear all interrupts in case they woke up active. */
for (i = 0; i < MAX_INTERRUPT_MASKS; i++) {
if(irq_clr_add[i] != RICOH619_INT_IR_RTC)
{
ret = ricoh619_write(ricoh619->dev,
irq_clr_add[i], 0);
if (ret < 0)
dev_err(ricoh619->dev, "Error in writing reg 0x%02x "
"error: %d\n", irq_clr_add[i], ret);
}
else
{
ret = ricoh619_read(ricoh619->dev,
RICOH619_INT_IR_RTC, &reg_data);
if (ret < 0)
dev_err(ricoh619->dev, "Error in reading reg 0x%02x "
"error: %d\n", RICOH619_INT_IR_RTC, ret);
reg_data &= 0xf0;
ret = ricoh619_write(ricoh619->dev,
RICOH619_INT_IR_RTC, reg_data);
if (ret < 0)
dev_err(ricoh619->dev, "Error in writing reg 0x%02x "
"error: %d\n", RICOH619_INT_IR_RTC, ret);
}
}
if (pdata->irq_gpio && !ricoh619->chip_irq) {
ricoh619->chip_irq = gpio_to_irq(pdata->irq_gpio);
if (pdata->irq_gpio) {
ret = gpio_request(pdata->irq_gpio, "ricoh619_pmic_irq");
if (ret < 0) {
dev_err(ricoh619->dev,
"Failed to request gpio %d with ret:"
"%d\n", pdata->irq_gpio, ret);
return IRQ_NONE;
}
gpio_direction_input(pdata->irq_gpio);
val = gpio_get_value(pdata->irq_gpio);
if (val){
irq_type = IRQ_TYPE_LEVEL_LOW;
flags = IRQF_TRIGGER_LOW;
}
else{
irq_type = IRQ_TYPE_LEVEL_HIGH;
flags = IRQF_TRIGGER_HIGH;
}
gpio_free(pdata->irq_gpio);
pr_info("%s: ricoh619_pmic_irq=%x\n", __func__, val);
}
}
domain = irq_domain_add_linear(NULL, RICOH619_NR_IRQS,
&ricoh619_irq_domain_ops, ricoh619);
if (!domain) {
dev_err(ricoh619->dev, "could not create irq domain\n");
return -ENODEV;
}
ricoh619->irq_domain = domain;
ret = devm_request_threaded_irq(ricoh619->dev,ricoh619->chip_irq, NULL, ricoh619_irq, flags |IRQF_ONESHOT, "ricoh619", ricoh619);
// ret = devm_request_threaded_irq(ricoh619->dev,ricoh619->chip_irq, NULL, ricoh619_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT , "ricoh619", ricoh619);
irq_set_irq_type(ricoh619->chip_irq, irq_type);
enable_irq_wake(ricoh619->chip_irq);
return ret;
}
int ricoh619_irq_exit(struct ricoh619 *ricoh619)
{
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,690 +0,0 @@
/*
* drivers/regulator/ricoh619-regulator.c
*
* Regulator driver for RICOH619 power management chip.
*
* Copyright (C) 2012-2013 RICOH COMPANY,LTD
*
* Based on code
* Copyright (C) 2011 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*#define DEBUG 1*/
/*#define VERBOSE_DEBUG 1*/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/mfd/ricoh619.h>
#include <linux/regulator/ricoh619-regulator.h>
#include <linux/of.h>
#include <linux/regulator/of_regulator.h>
struct ricoh619_regulator {
int id;
int sleep_id;
/* Regulator register address.*/
u8 reg_en_reg;
u8 en_bit;
u8 reg_disc_reg;
u8 disc_bit;
u8 vout_reg;
u8 vout_mask;
u8 vout_reg_cache;
u8 sleep_reg;
u8 eco_reg;
u8 eco_bit;
u8 eco_slp_reg;
u8 eco_slp_bit;
/* chip constraints on regulator behavior */
int min_uV;
int max_uV;
int step_uV;
int nsteps;
/* regulator specific turn-on delay */
u16 delay;
/* used by regulator core */
struct regulator_desc desc;
/* Device */
struct device *dev;
};
//static unsigned int ricoh619_suspend_status = 0;
static inline struct device *to_ricoh619_dev(struct regulator_dev *rdev)
{
return rdev_get_dev(rdev)->parent->parent;
}
/*
static int ricoh619_regulator_enable_time(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
return ri->delay;
}
*/
static int ricoh619_reg_is_enabled(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
uint8_t control;
int ret;
ret = ricoh619_read(parent, ri->reg_en_reg, &control);
if (ret < 0) {
dev_err(&rdev->dev, "Error in reading the control register\n");
return ret;
}
return (((control >> ri->en_bit) & 1) == 1);
}
static int ricoh619_reg_enable(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
ret = ricoh619_set_bits(parent, ri->reg_en_reg, (1 << ri->en_bit));
if (ret < 0) {
dev_err(&rdev->dev, "Error in updating the STATE register\n");
return ret;
}
udelay(ri->delay);
return ret;
}
static int ricoh619_reg_disable(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
ret = ricoh619_clr_bits(parent, ri->reg_en_reg, (1 << ri->en_bit));
if (ret < 0)
dev_err(&rdev->dev, "Error in updating the STATE register\n");
return ret;
}
static int ricoh619_list_voltage(struct regulator_dev *rdev, unsigned index)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
return ri->min_uV + (ri->step_uV * index);
}
static int __ricoh619_set_s_voltage(struct device *parent,
struct ricoh619_regulator *ri, int min_uV, int max_uV)
{
int vsel;
int ret;
if ((min_uV < ri->min_uV) || (max_uV > ri->max_uV))
return -EDOM;
vsel = (min_uV - ri->min_uV + ri->step_uV - 1)/ri->step_uV;
if (vsel > ri->nsteps)
return -EDOM;
ret = ricoh619_update(parent, ri->sleep_reg, vsel, ri->vout_mask);
if (ret < 0)
dev_err(ri->dev, "Error in writing the sleep register\n");
return ret;
}
static int __ricoh619_set_voltage(struct device *parent,
struct ricoh619_regulator *ri, int min_uV, int max_uV,
unsigned *selector)
{
int vsel;
int ret;
uint8_t vout_val;
if ((min_uV < ri->min_uV) || (max_uV > ri->max_uV))
return -EDOM;
vsel = (min_uV - ri->min_uV + ri->step_uV - 1)/ri->step_uV;
if (vsel > ri->nsteps)
return -EDOM;
if (selector)
*selector = vsel;
vout_val = (ri->vout_reg_cache & ~ri->vout_mask) |
(vsel & ri->vout_mask);
ret = ricoh619_write(parent, ri->vout_reg, vout_val);
if (ret < 0)
dev_err(ri->dev, "Error in writing the Voltage register\n");
else
ri->vout_reg_cache = vout_val;
return ret;
}
static int ricoh619_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
// if(ricoh619_suspend_status)
// return -EBUSY;
return __ricoh619_set_voltage(parent, ri, min_uV, max_uV, selector);
}
static int ricoh619_set_suspend_voltage(struct regulator_dev *rdev,
int uV)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
return __ricoh619_set_s_voltage(parent, ri, uV, uV);
}
static int ricoh619_get_voltage(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
uint8_t vsel;
int ret;
ret = ricoh619_read(parent, ri->vout_reg, &vsel);
return ricoh619_list_voltage(rdev,vsel);
}
int ricoh619_regulator_enable_eco_mode(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
ret = ricoh619_set_bits(parent, ri->eco_reg, (1 << ri->eco_bit));
if (ret < 0)
dev_err(&rdev->dev, "Error Enable LDO eco mode\n");
return ret;
}
EXPORT_SYMBOL_GPL(ricoh619_regulator_enable_eco_mode);
int ricoh619_regulator_disable_eco_mode(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
ret = ricoh619_clr_bits(parent, ri->eco_reg, (1 << ri->eco_bit));
if (ret < 0)
dev_err(&rdev->dev, "Error Disable LDO eco mode\n");
return ret;
}
EXPORT_SYMBOL_GPL(ricoh619_regulator_disable_eco_mode);
int ricoh619_regulator_enable_eco_slp_mode(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
ret = ricoh619_set_bits(parent, ri->eco_slp_reg, (1 << ri->eco_slp_bit));
if (ret < 0)
dev_err(&rdev->dev, "Error Enable LDO eco mode in d during sleep\n");
return ret;
}
EXPORT_SYMBOL_GPL(ricoh619_regulator_enable_eco_slp_mode);
int ricoh619_regulator_disable_eco_slp_mode(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
ret = ricoh619_clr_bits(parent, ri->eco_slp_reg, (1 << ri->eco_slp_bit));
if (ret < 0)
dev_err(&rdev->dev, "Error Enable LDO eco mode in d during sleep\n");
return ret;
}
EXPORT_SYMBOL_GPL(ricoh619_regulator_disable_eco_slp_mode);
static unsigned int ricoh619_dcdc_get_mode(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
uint8_t control;
u8 mask = 0x30;
ret = ricoh619_read(parent, ri->reg_en_reg,&control);
if (ret < 0) {
return ret;
}
control=(control & mask) >> 4;
switch (control) {
case 1:
return REGULATOR_MODE_FAST;
case 0:
return REGULATOR_MODE_NORMAL;
case 2:
return REGULATOR_MODE_STANDBY;
case 3:
return REGULATOR_MODE_NORMAL;
default:
return -1;
}
}
static int ricoh619_dcdc_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
uint8_t control;
ret = ricoh619_read(parent, ri->reg_en_reg,&control);
switch(mode)
{
case REGULATOR_MODE_FAST:
return ricoh619_write(parent, ri->reg_en_reg, ((control & 0xcf) | 0x10));
case REGULATOR_MODE_NORMAL:
return ricoh619_write(parent, ri->reg_en_reg, (control & 0xcf));
case REGULATOR_MODE_STANDBY:
return ricoh619_write(parent, ri->reg_en_reg, ((control & 0xcf) | 0x20));
default:
printk("error:pmu_619 only powersave pwm psm mode\n");
return -EINVAL;
}
}
static int ricoh619_dcdc_set_voltage_time_sel(struct regulator_dev *rdev, unsigned int old_selector,
unsigned int new_selector)
{
int old_volt, new_volt;
old_volt = ricoh619_list_voltage(rdev, old_selector);
if (old_volt < 0)
return old_volt;
new_volt = ricoh619_list_voltage(rdev, new_selector);
if (new_volt < 0)
return new_volt;
return DIV_ROUND_UP(abs(old_volt - new_volt)*2, 14000);
}
static int ricoh619_dcdc_set_suspend_mode(struct regulator_dev *rdev, unsigned int mode)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
uint8_t control;
ret = ricoh619_read(parent, ri->reg_en_reg,&control);
switch(mode)
{
case REGULATOR_MODE_FAST:
return ricoh619_write(parent, ri->reg_en_reg, ((control & 0x3f) | 0x40));
case REGULATOR_MODE_NORMAL:
return ricoh619_write(parent, ri->reg_en_reg, (control & 0x3f));
case REGULATOR_MODE_STANDBY:
return ricoh619_write(parent, ri->reg_en_reg, ((control & 0x3f) | 0x80));
default:
printk("error:pmu_619 only powersave pwm psm mode\n");
return -EINVAL;
}
}
static int ricoh619_reg_suspend_enable(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
ret = ricoh619_set_bits(parent, (0x16 + ri->id), (0xf << 0));
if (ret < 0) {
dev_err(&rdev->dev, "Error in updating the STATE register\n");
return ret;
}
udelay(ri->delay);
return ret;
}
static int ricoh619_reg_suspend_disable(struct regulator_dev *rdev)
{
struct ricoh619_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_ricoh619_dev(rdev);
int ret;
ret = ricoh619_clr_bits(parent, (0x16 + ri->id), (0xf <<0));
if (ret < 0)
dev_err(&rdev->dev, "Error in updating the STATE register\n");
return ret;
}
static struct regulator_ops ricoh619_ops = {
.list_voltage = ricoh619_list_voltage,
.set_voltage = ricoh619_set_voltage,
.get_voltage = ricoh619_get_voltage,
.set_suspend_voltage = ricoh619_set_suspend_voltage,
.set_voltage_time_sel = ricoh619_dcdc_set_voltage_time_sel,
.get_mode = ricoh619_dcdc_get_mode,
.set_mode = ricoh619_dcdc_set_mode,
.enable = ricoh619_reg_enable,
.disable = ricoh619_reg_disable,
.set_suspend_mode = ricoh619_dcdc_set_suspend_mode,
.set_suspend_enable = ricoh619_reg_suspend_enable,
.set_suspend_disable = ricoh619_reg_suspend_disable,
.is_enabled = ricoh619_reg_is_enabled,
};
#define RICOH619_REG(_id, _en_reg, _en_bit, _disc_reg, _disc_bit, _vout_reg, \
_vout_mask, _ds_reg, _min_uv, _max_uv, _step_uV, _nsteps, \
_ops, _delay, _eco_reg, _eco_bit, _eco_slp_reg, _eco_slp_bit) \
{ \
.reg_en_reg = _en_reg, \
.en_bit = _en_bit, \
.reg_disc_reg = _disc_reg, \
.disc_bit = _disc_bit, \
.vout_reg = _vout_reg, \
.vout_mask = _vout_mask, \
.sleep_reg = _ds_reg, \
.min_uV = _min_uv, \
.max_uV = _max_uv , \
.step_uV = _step_uV, \
.nsteps = _nsteps, \
.delay = _delay, \
.id = RICOH619_ID_##_id, \
.sleep_id = RICOH619_DS_##_id, \
.eco_reg = _eco_reg, \
.eco_bit = _eco_bit, \
.eco_slp_reg = _eco_slp_reg, \
.eco_slp_bit = _eco_slp_bit, \
.desc = { \
.name = ricoh619_rails(_id), \
.id = RICOH619_ID_##_id, \
.n_voltages = _nsteps, \
.ops = &_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
}, \
}
static struct ricoh619_regulator ricoh619_regulator_data[] = {
RICOH619_REG(DC1, 0x2C, 0, 0x2C, 1, 0x36, 0xFF, 0x3B,
600000, 3500000, 12500, 0xE8, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(DC2, 0x2E, 0, 0x2E, 1, 0x37, 0xFF, 0x3C,
600000, 3500000, 12500, 0xE8, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(DC3, 0x30, 0, 0x30, 1, 0x38, 0xFF, 0x3D,
600000, 3500000, 12500, 0xE8, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(DC4, 0x32, 0, 0x32, 1, 0x39, 0xFF, 0x3E,
600000, 3500000, 12500, 0xE8, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(DC5, 0x34, 0, 0x34, 1, 0x3A, 0xFF, 0x3F,
600000, 3500000, 12500, 0xE8, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(LDO1, 0x44, 0, 0x46, 0, 0x4C, 0x7F, 0x58,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x48, 0, 0x4A, 0),
RICOH619_REG(LDO2, 0x44, 1, 0x46, 1, 0x4D, 0x7F, 0x59,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x48, 1, 0x4A, 1),
RICOH619_REG(LDO3, 0x44, 2, 0x46, 2, 0x4E, 0x7F, 0x5A,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x48, 2, 0x4A, 2),
RICOH619_REG(LDO4, 0x44, 3, 0x46, 3, 0x4F, 0x7F, 0x5B,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x48, 3, 0x4A, 3),
RICOH619_REG(LDO5, 0x44, 4, 0x46, 4, 0x50, 0x7F, 0x5C,
600000, 3500000, 25000, 0x74, ricoh619_ops, 500,
0x48, 4, 0x4A, 4),
RICOH619_REG(LDO6, 0x44, 5, 0x46, 5, 0x51, 0x7F, 0x5D,
600000, 3500000, 25000, 0x74, ricoh619_ops, 500,
0x48, 5, 0x4A, 5),
RICOH619_REG(LDO7, 0x44, 6, 0x46, 6, 0x52, 0x7F, 0x5E,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(LDO8, 0x44, 7, 0x46, 7, 0x53, 0x7F, 0x5F,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(LDO9, 0x45, 0, 0x47, 0, 0x54, 0x7F, 0x60,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(LDO10, 0x45, 1, 0x47, 1, 0x55, 0x7F, 0x61,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(LDORTC1, 0x45, 4, 0x00, 0, 0x56, 0x7F, 0x00,
1700000, 3500000, 25000, 0x48, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
RICOH619_REG(LDORTC2, 0x45, 5, 0x00, 0, 0x57, 0x7F, 0x00,
900000, 3500000, 25000, 0x68, ricoh619_ops, 500,
0x00, 0, 0x00, 0),
};
static inline struct ricoh619_regulator *find_regulator_info(int id)
{
struct ricoh619_regulator *ri;
int i;
for (i = 0; i < ARRAY_SIZE(ricoh619_regulator_data); i++) {
ri = &ricoh619_regulator_data[i];
if (ri->desc.id == id)
return ri;
}
return NULL;
}
#if 0
static int ricoh619_regulator_preinit(struct device *parent,
struct ricoh619_regulator *ri,
struct ricoh619_regulator_platform_data *ricoh619_pdata)
{
int ret = 0;
if (!ricoh619_pdata->init_apply)
return 0;
/*
if (ricoh619_pdata->init_uV >= 0) {
ret = __ricoh619_set_voltage(parent, ri,
ricoh619_pdata->init_uV,
ricoh619_pdata->init_uV, 0);
if (ret < 0) {
dev_err(ri->dev, "Not able to initialize voltage %d "
"for rail %d err %d\n", ricoh619_pdata->init_uV,
ri->desc.id, ret);
return ret;
}
}
*/
if (ricoh619_pdata->init_enable)
ret = ricoh619_set_bits(parent, ri->reg_en_reg,
(1 << ri->en_bit));
else
ret = ricoh619_clr_bits(parent, ri->reg_en_reg,
(1 << ri->en_bit));
if (ret < 0)
dev_err(ri->dev, "Not able to %s rail %d err %d\n",
(ricoh619_pdata->init_enable) ? "enable" : "disable",
ri->desc.id, ret);
return ret;
}
#endif
static inline int ricoh619_cache_regulator_register(struct device *parent,
struct ricoh619_regulator *ri)
{
ri->vout_reg_cache = 0;
return ricoh619_read(parent, ri->vout_reg, &ri->vout_reg_cache);
}
#ifdef CONFIG_OF
static struct of_regulator_match ricoh619_regulator_matches[] = {
{ .name = "ricoh619_dc1",},
{ .name = "ricoh619_dc2",},
{ .name = "ricoh619_dc3",},
{ .name = "ricoh619_dc4",},
{ .name = "ricoh619_dc5",},
{ .name = "ricoh619_ldo1",},
{ .name = "ricoh619_ldo2",},
{ .name = "ricoh619_ldo3",},
{ .name = "ricoh619_ldo4",},
{ .name = "ricoh619_ldo5",},
{ .name = "ricoh619_ldo6",},
{ .name = "ricoh619_ldo7",},
{ .name = "ricoh619_ldo8",},
{ .name = "ricoh619_ldo9",},
{ .name = "ricoh619_ldo10",},
{ .name = "ricoh619_ldortc1",},
{ .name = "ricoh619_ldortc2",},
};
#endif
#ifdef CONFIG_OF
static int ricoh619_regulator_dt_init(struct platform_device *pdev,
struct regulator_config *config,
int regidx)
{
struct device_node *nproot, *np;
int rcount;
nproot = of_node_get(pdev->dev.parent->of_node);
if (!nproot)
return -ENODEV;
np = of_find_node_by_name(nproot, "regulators");
if (!np) {
dev_err(&pdev->dev, "failed to find regulators node\n");
return -ENODEV;
}
rcount = of_regulator_match(&pdev->dev, np,
&ricoh619_regulator_matches[regidx], 1);
of_node_put(np);
if (rcount < 0)
return -ENODEV;
config->init_data = ricoh619_regulator_matches[regidx].init_data;
config->of_node = ricoh619_regulator_matches[regidx].of_node;
return 0;
}
#else
#define ricoh619_regulator_dt_init(x, y, z) (-1)
#endif
static int ricoh619_regulator_probe(struct platform_device *pdev)
{
struct ricoh619_regulator *ri = NULL;
struct regulator_dev *rdev;
struct regulator_config config = { };
int err,id=0;
rdev = devm_kzalloc(&pdev->dev, RICOH619_NUM_REGULATOR *
sizeof(*rdev), GFP_KERNEL);
if (!rdev) {
dev_err(&pdev->dev, "Mmemory alloc failed\n");
return -ENOMEM;
}
for (id = 0; id < RICOH619_NUM_REGULATOR; ++id) {
ri = find_regulator_info(id);
if (!ri) {
dev_err(&pdev->dev, "invalid regulator ID specified\n");
err = -EINVAL;
}
ri->dev = &pdev->dev;
config.dev = &pdev->dev;
config.driver_data = ri;
config.of_node = ricoh619_regulator_matches[id].of_node;
err = ricoh619_regulator_dt_init(pdev, &config, id);
if (err < 0) {
dev_err(&pdev->dev, "failed to regulator dt init\n");
}
rdev = regulator_register(&ri->desc, &config);
if (IS_ERR_OR_NULL(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
ri->desc.name);
return PTR_ERR(rdev);
}
}
platform_set_drvdata(pdev, rdev);
return 0;
}
static int ricoh619_regulator_remove(struct platform_device *pdev)
{
struct regulator_dev *rdev = platform_get_drvdata(pdev);
regulator_unregister(rdev);
return 0;
}
static struct platform_driver ricoh619_regulator_driver = {
.driver = {
.name = "ricoh619-regulator",
.owner = THIS_MODULE,
},
.probe = ricoh619_regulator_probe,
.remove = ricoh619_regulator_remove,
};
static int __init ricoh619_regulator_init(void)
{
return platform_driver_register(&ricoh619_regulator_driver);
}
subsys_initcall_sync(ricoh619_regulator_init);
static void __exit ricoh619_regulator_exit(void)
{
platform_driver_unregister(&ricoh619_regulator_driver);
}
module_exit(ricoh619_regulator_exit);
MODULE_DESCRIPTION("RICOH619 regulator driver");
MODULE_ALIAS("platform:ricoh619-regulator");
MODULE_AUTHOR("zhangqing <zhangqing@rock-chips.com>");
MODULE_LICENSE("GPL");

View File

@@ -1,845 +0,0 @@
/*
* drivers/rtc/rtc-ricoh619.c
*
* Real time clock driver for RICOH RC5T619 power management chip.
*
* Copyright (C) 2012-2013 RICOH COMPANY,LTD
*
* Based on code
* Copyright (C) 2011 NVIDIA Corporation
*
* this program is free software; you can redistribute it and/or modify
* it under the terms of the gnu general public license as published by
* the free software foundation; either version 2 of the license, or
* (at your option) any later version.
*
* this program is distributed in the hope that it will be useful, but without
* any warranty; without even the implied warranty of merchantability or
* fitness for a particular purpose. see the gnu general public license for
* more details.
*
* you should have received a copy of the gnu general public license
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* #define debug 1 */
/* #define verbose_debug 1 */
#include <linux/device.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mfd/ricoh619.h>
#include <linux/rtc/rtc-ricoh619.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
#include <linux/slab.h>
#include <linux/irqdomain.h>
struct ricoh619_rtc {
int irq;
struct rtc_device *rtc;
bool irq_en;
};
static int ricoh619_read_regs(struct device *dev, int reg, int len,
uint8_t *val)
{
int ret;
ret = ricoh619_bulk_reads(dev->parent, reg, len, val);
if (ret < 0) {
dev_err(dev->parent, "\n %s failed reading from 0x%02x\n",
__func__, reg);
WARN_ON(1);
}
return ret;
}
static int ricoh619_write_regs(struct device *dev, int reg, int len,
uint8_t *val)
{
int ret;
ret = ricoh619_bulk_writes(dev->parent, reg, len, val);
if (ret < 0) {
dev_err(dev->parent, "\n %s failed writing\n", __func__);
WARN_ON(1);
}
return ret;
}
// 0=OK, -EINVAL= FAIL
static int ricoh619_rtc_valid_tm(struct device *dev, struct rtc_time *tm)
{
if (tm->tm_year > 199 || tm->tm_year < 70
|| tm->tm_mon > 11 || tm->tm_mon < 0
|| tm->tm_mday < 1
|| tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + os_ref_year)
|| tm->tm_hour >= 24 || tm->tm_hour < 0
|| tm->tm_min < 0 || tm->tm_min >= 60
|| tm->tm_sec < 0 || tm->tm_sec >= 60
)
{
dev_err(dev->parent, "PMU: %s *** Returning error due to time, %d/%d/%d %d:%d:%d *****\n",
__func__, tm->tm_mon, tm->tm_mday, tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec);
return -EINVAL;
}
return 0;
}
static u8 dec2bcd(u8 dec)
{
return ((dec/10)<<4)+(dec%10);
}
static u8 bcd2dec(u8 bcd)
{
return (bcd >> 4)*10+(bcd & 0xf);
}
static void convert_bcd_to_decimal(u8 *buf, u8 len)
{
int i = 0;
for (i = 0; i < len; i++)
buf[i] = bcd2dec(buf[i]);
}
static void convert_decimal_to_bcd(u8 *buf, u8 len)
{
int i = 0;
for (i = 0; i < len; i++)
buf[i] = dec2bcd(buf[i]);
}
static void print_time(struct device *dev, struct rtc_time *tm)
{
dev_info(dev, "PMU: %s *** rtc-time : %d/%d/%d %d:%d:%d *****\n",
__func__, (tm->tm_mon), tm->tm_mday, (tm->tm_year + os_ref_year), tm->tm_hour, tm->tm_min,tm->tm_sec);
}
static int ricoh619_rtc_periodic_disable(struct device *dev)
{
int err;
uint8_t reg_data;
// disable function
err = ricoh619_read_regs(dev, rtc_ctrl1, 1, &reg_data);
if(err < 0)
{
dev_err(dev->parent, "read rtc_ctrl1 error=0x%x\n", err);
return err;
}
reg_data &= 0xf8;
err = ricoh619_write_regs(dev, rtc_ctrl1, 1, &reg_data);
if(err < 0)
{
dev_err(dev->parent, "read rtc_ctrl1 error=0x%x\n", err);
return err;
}
// clear alarm flag and CTFG
err = ricoh619_read_regs(dev, rtc_ctrl2, 1, &reg_data);
if(err < 0)
{
dev_err(dev->parent, "read rtc_ctrl2 error=0x%x\n", err);
return err;
}
reg_data &= ~0x85;// 1000-0101
err = ricoh619_write_regs(dev, rtc_ctrl2, 1, &reg_data);
if(err < 0)
{
dev_err(dev->parent, "read rtc_ctrl2 error=0x%x\n", err);
return err;
}
return 0;
}
static int ricoh619_rtc_clk_adjust(struct device *dev, uint8_t clk)
{
return ricoh619_write_regs(dev, rtc_adjust, 1, &clk);
}
static int ricoh619_rtc_Pon_get_clr(struct device *dev, uint8_t *Pon_f)
{
int err;
uint8_t reg_data;
err = ricoh619_read_regs(dev, rtc_ctrl2,1,&reg_data);
if(err < 0)
{
dev_err(dev->parent, "rtc_ctrl1 read err=0x%x\n", err);
return err;
}
// printk("%s,PON=1 -- CTRL2=0x%x\n", __func__, reg_data);
if(reg_data & 0x10)
{
*Pon_f = 1;
//clear VDET PON
reg_data &= ~0x5b;// 0101-1011
reg_data |= 0x20; // 0010-0000
err = ricoh619_write_regs(dev, rtc_ctrl2, 1,&reg_data);
if(err < 0)
{
dev_err(dev->parent, "rtc_ctrl1 write err=0x%x\n", err);
}
}
else
{
*Pon_f = 0;
}
return err;
}
// 0-12hour, 1-24hour
/*
static int ricoh619_rtc_hour_mode_get(struct device *dev, uint8_t *mode)
{
int err;
err = ricoh619_read_regs(dev, rtc_ctrl1, 1, mode);
if(err < 0)
dev_err(dev->parent, "read rtc ctrl1 error\n");
if(*mode & 0x20)
*mode = 1;
else
*mode = 0;
return err;
}
*/
// 0-12hour, 1-24hour
static int ricoh619_rtc_hour_mode_set(struct device *dev, int mode)
{
uint8_t reg_data;
int err;
err = ricoh619_read_regs(dev, rtc_ctrl1, 1, &reg_data);
if(err < 0)
{
dev_err(dev->parent, "read rtc_ctrl1 error\n");
return err;
}
if(mode == 0)
reg_data &= 0xDF;
else
reg_data |= 0x20;
err = ricoh619_write_regs(dev, rtc_ctrl1, 1, &reg_data);
if(err < 0)
{
dev_err(dev->parent, "write rtc_ctrl1 error\n");
}
return err;
}
static int ricoh619_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
u8 buff[7];
int err;
int cent_flag;
err = ricoh619_read_regs(dev, rtc_seconds_reg, sizeof(buff), buff);
if (err < 0) {
dev_err(dev->parent, "PMU: %s *** failed to read time *****\n", __func__);
return err;
}
if (buff[5] & 0x80)
cent_flag = 1;
else
cent_flag = 0;
buff[5] = buff[5]&0x1f; //bit5 19_20
convert_bcd_to_decimal(buff, sizeof(buff));
tm->tm_sec = buff[0];
tm->tm_min = buff[1];
tm->tm_hour = buff[2]; //bit5 PA_H20
tm->tm_wday = buff[3];
tm->tm_mday = buff[4];
tm->tm_mon = buff[5]; //for print
tm->tm_year = buff[6] + 100 * cent_flag;
print_time(dev, tm); //for print
tm->tm_mon = buff[5] - 1; //back to system 0-11
// printk(KERN_INFO "PMU: %s year=%d mon=%d day=% hour=%d min =%d sec=%d\n", __func__,
// tm->tm_year,tm->tm_mon ,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec );
return 0;
}
static int ricoh619_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
u8 buff[7];
int err;
int cent_flag;
// printk(KERN_INFO "PMU: %s year=%d mon=%d day=% hour=%d min =%d sec=%d\n", __func__,
// tm->tm_year,tm->tm_mon ,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec );
if(ricoh619_rtc_valid_tm(dev, tm) != 0)
{
return -EINVAL;
}
if (tm->tm_year >= 100)
cent_flag = 1;
else
cent_flag = 0;
tm->tm_mon = tm->tm_mon + 1;
buff[0] = tm->tm_sec;
buff[1] = tm->tm_min;
buff[2] = tm->tm_hour;
buff[3] = tm->tm_wday;
buff[4] = tm->tm_mday;
buff[5] = tm->tm_mon; //system set 0-11
buff[6] = tm->tm_year - 100 * cent_flag;
print_time(dev, tm); // RTC_TEST
convert_decimal_to_bcd(buff, sizeof(buff));
if (1 == cent_flag)
buff[5] |= 0x80;
err = ricoh619_write_regs(dev, rtc_seconds_reg, sizeof(buff), buff);
if (err < 0) {
dev_err(dev->parent, "\n failed to program new time\n");
return err;
}
return 0;
}
static int ricoh619_rtc_alarm_is_enabled(struct device *dev, uint8_t *enabled)
{
int err;
uint8_t reg_data;
err = 0;
err = ricoh619_read_regs(dev, rtc_ctrl1,1,&reg_data);
if(err<0)
{
dev_err(dev->parent, "read rtc_ctrl1 error 0x%x\n", err);
*enabled = 0;
}
else
{
if(reg_data & 0x40)
*enabled = 1;
else
*enabled = 0;
}
return err;
}
// 0-disable, 1-enable
static int ricoh619_rtc_alarm_enable(struct device *dev, unsigned int enabled)
{
struct ricoh619_rtc *rtc = dev_get_drvdata(dev);
int err;
uint8_t reg_data;
// printk(KERN_INFO "PMU: %s :%d\n", __func__,enabled);
err = 0;
if(enabled)
{
rtc->irq_en = 1;
err = ricoh619_read_regs(dev, rtc_ctrl1, 1,&reg_data);
if(err < 0)
{
dev_err(dev->parent, "read rtc_ctrl1 error =%d\n", err);
goto ERR;
}
reg_data |= 0x40;// set DALE
err = ricoh619_write_regs(dev, rtc_ctrl1, 1,&reg_data);
if(dev < 0)
dev_err(dev->parent, "write rtc_ctrl1 error =%d\n", err);
}
else
{
rtc->irq_en = 0;
err = ricoh619_read_regs(dev, rtc_ctrl1, 1,&reg_data);
if(err < 0)
{
dev_err(dev->parent, "read rtc_ctrl1 error =%d\n", err);
goto ERR;
}
reg_data &= 0xbf;// clear DALE
err = ricoh619_write_regs(dev, rtc_ctrl1, 1,&reg_data);
if(dev < 0)
dev_err(dev->parent, "write rtc_ctrl1 error =%d\n", err);
}
ERR:
return err;
}
static int ricoh619_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
u8 buff[6];
u8 buff_cent;
int err;
int cent_flag;
unsigned char enabled_flag;
// printk(KERN_INFO "PMU: %s\n", __func__);
err = 0;
alrm->time.tm_sec = 0;
alrm->time.tm_min = 0;
alrm->time.tm_hour = 0;
alrm->time.tm_mday = 0;
alrm->time.tm_mon = 0;
alrm->time.tm_year = 0;
alrm->enabled = 0;
err = ricoh619_read_regs(dev, rtc_month_reg, 1, &buff_cent);
if (err < 0) {
dev_err(dev->parent, "PMU: %s *** failed to read time *****\n", __func__);
return err;
}
if (buff_cent & 0x80)
cent_flag = 1;
else
cent_flag = 0;
err = ricoh619_read_regs(dev, rtc_alarm_y_sec, sizeof(buff), buff);
if(err <0)
{
dev_err(dev->parent, "RTC: %s *** read rtc_alarm timer error =%d\n", __func__, err);
return err;
}
err = ricoh619_read_regs(dev, rtc_ctrl1, 1,&enabled_flag);
if(err<0)
{
dev_err(dev->parent, "RTC: %s *** read rtc_enable flag error =%d\n", __func__, err);
return err;
}
if(enabled_flag & 0x40)
enabled_flag = 1;
else
enabled_flag = 0;
buff[3] &= ~0x80; /* clear DAL_EXT */
buff[3] = buff[3]&0x3f;
convert_bcd_to_decimal(buff, sizeof(buff));
alrm->time.tm_sec = buff[0];
alrm->time.tm_min = buff[1];
alrm->time.tm_hour = buff[2];
alrm->time.tm_mday = buff[3];
alrm->time.tm_mon = buff[4];// for print
alrm->time.tm_year = buff[5] + 100 * cent_flag;
dev_info(dev, "PMU: read alarm: %d/%d/%d %d:%d:%d *****\n",
(alrm->time.tm_mon), alrm->time.tm_mday, (alrm->time.tm_year + os_ref_year), alrm->time.tm_hour, alrm->time.tm_min,alrm->time.tm_sec);
alrm->time.tm_mon = buff[4] - 1;
alrm->enabled = enabled_flag;
return 0;
}
static int ricoh619_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct ricoh619_rtc *rtc = dev_get_drvdata(dev);
u8 buff[6];
int err;
int cent_flag;
// printk(KERN_INFO "PMU: %s\n", __func__);
err = 0;
ricoh619_rtc_alarm_enable(dev, 0);
if (rtc->irq == -1)
{
err = -EIO;
goto ERR;
}
if(alrm->enabled== 0)
return 0;
if (alrm->time.tm_year >= 100)
cent_flag = 1;
else
cent_flag = 0;
alrm->time.tm_mon += 1;
print_time(dev->parent, &alrm->time);
buff[0] = alrm->time.tm_sec;
buff[1] = alrm->time.tm_min;
buff[2] = alrm->time.tm_hour;
buff[3] = alrm->time.tm_mday;
buff[4] = alrm->time.tm_mon;
// buff[5] = alrm->time.tm_year - rtc_year_offset;
buff[5] = alrm->time.tm_year - 100 * cent_flag;
convert_decimal_to_bcd(buff, sizeof(buff));
buff[3] |= 0x80; /* set DAL_EXT */
err = ricoh619_write_regs(dev, rtc_alarm_y_sec, sizeof(buff), buff);
if (err<0) {
dev_err(dev->parent, "\n unable to set alarm\n");
err = -EBUSY;
goto ERR;
}
ricoh619_rtc_alarm_enable(dev, alrm->enabled);
ERR:
return err;
}
static const struct rtc_class_ops ricoh619_rtc_ops = {
.read_time = ricoh619_rtc_read_time,
.set_time = ricoh619_rtc_set_time,
.set_alarm = ricoh619_rtc_set_alarm,
.read_alarm = ricoh619_rtc_read_alarm,
.alarm_irq_enable = ricoh619_rtc_alarm_enable,
};
static int ricoh619_rtc_alarm_flag_clr(struct device *dev)
{
int err;
uint8_t reg_data;
/* clear alarm-D status bits.*/
err = ricoh619_read_regs(dev, rtc_ctrl2, 1, &reg_data);
if (err<0)
dev_err(dev->parent, "unable to read rtc_ctrl2 reg\n");
/* to clear alarm-D flag, and set adjustment parameter */
reg_data &= ~0x81;
err = ricoh619_write_regs(dev, rtc_ctrl2, 1, &reg_data);
if (err<0)
dev_err(dev->parent, "unable to program rtc_status reg\n");
return err;
}
static irqreturn_t ricoh619_rtc_irq(int irq, void *data)
{
struct device *dev = data;
struct ricoh619_rtc *rtc = dev_get_drvdata(dev);
// printk(KERN_INFO "PMU: %s\n", __func__);
ricoh619_rtc_alarm_flag_clr(dev);
rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF);
return IRQ_HANDLED;
}
#ifdef CONFIG_OF
static struct ricoh619_rtc_platform_data *ricoh619_rtc_dt_init(struct platform_device *pdev)
{
struct device_node *nproot = pdev->dev.parent->of_node;
struct device_node *np;
struct ricoh619_rtc_platform_data *pdata;
if (!nproot)
return pdev->dev.platform_data;
np = of_find_node_by_name(nproot, "rtc");
if (!np) {
dev_err(&pdev->dev, "failed to find rtc node\n");
return NULL;
}
pdata = devm_kzalloc(&pdev->dev,
sizeof(struct ricoh619_rtc_platform_data),
GFP_KERNEL);
of_property_read_u32(np, "ricoh,rtc-tm-year", &pdata->time.tm_year);
of_property_read_u32(np, "ricoh,rtc-tm-month", &pdata->time.tm_mon);
of_property_read_u32(np, "ricoh,rtc-tm-mday", &pdata->time.tm_mday);
of_property_read_u32(np, "ricoh,rtc-tm-hour", &pdata->time.tm_hour);
of_property_read_u32(np, "ricoh,rtc-tm-min", &pdata->time.tm_min);
of_property_read_u32(np, "ricoh,rtc-tm-sec", &pdata->time.tm_sec);
of_node_put(np);
return pdata;
}
#else
static struct ricoh619_rtc_platform_data *
ricoh619_rtc_dt_init(struct platform_device *pdev)
{
return pdev->dev.platform_data;
}
#endif
static int ricoh619_rtc_probe(struct platform_device *pdev)
{
struct ricoh619_rtc_platform_data *pdata;
struct ricoh619 *ricoh619 = dev_get_drvdata(pdev->dev.parent);
struct ricoh619_rtc *rtc;
struct rtc_time tm;
uint8_t Pon_flag,Alarm_flag;
int err;
uint8_t buff[6];
// printk(KERN_INFO "******PMU RTC: Version 2014-01-01 REDS!******\n");
pdata = ricoh619_rtc_dt_init(pdev);
if (!pdata) {
dev_err(&pdev->dev, "platform data isn't assigned to "
"rtc\n");
return -EINVAL;
}
printk("%s,line=%d\n", __func__,__LINE__);
rtc = devm_kzalloc(ricoh619->dev,sizeof(*rtc), GFP_KERNEL);
if(IS_ERR(rtc))
{
err = PTR_ERR(rtc);
dev_err(&pdev->dev, "no enough memory for ricoh619_rtc using\n");
return -ENOMEM;
}
dev_set_drvdata(&pdev->dev, rtc);
if(IS_ERR(rtc->rtc))
{
err = PTR_ERR(rtc->rtc);
goto fail;
}
rtc->irq = irq_create_mapping(ricoh619->irq_domain, RICOH619_IRQ_DALE);
if(rtc->irq < 0)
{
dev_err(&pdev->dev, "\n no irq specified, wakeup is disabled\n");
rtc->irq = -1;
rtc->irq_en = 0;
}
else
rtc->irq_en = 1;
//get interrupt flag
err = ricoh619_rtc_alarm_is_enabled(&pdev->dev, &Alarm_flag);
if (err<0)
{
dev_err(&pdev->dev, "5T619 RTC: Disable alarm interrupt error\n");
goto fail;
}
// get PON flag
err = ricoh619_rtc_Pon_get_clr(&pdev->dev, &Pon_flag);
if (err<0)
{
dev_err(&pdev->dev, "5T619 RTC: get PON flag error\n");
goto fail;
}
// disable rtc periodic function
err = ricoh619_rtc_periodic_disable(&pdev->dev);
if (err<0)
{
dev_err(&pdev->dev, "5T619 RTC: disable rtc periodic int error\n");
goto fail;
}
// clearing RTC Adjust register
err = ricoh619_rtc_clk_adjust(&pdev->dev, 0);
if (err<0)
{
dev_err(&pdev->dev, "unable to program rtc_adjust reg\n");
err = -EBUSY;
goto fail;
}
//disable interrupt
err = ricoh619_rtc_alarm_enable(&pdev->dev, 0);
if (err<0)
{
dev_err(&pdev->dev, "5T619 RTC: Disable alarm interrupt error\n");
goto fail;
}
// PON=1
if(Pon_flag)
{
Alarm_flag = 0;
// clear int flag
err = ricoh619_rtc_alarm_flag_clr(&pdev->dev);
if (err<0)
{
dev_err(&pdev->dev, "5T619 RTC: Pon=1 clear alarm flag error\n");
goto fail;
}
// using 24h-mode
err = ricoh619_rtc_hour_mode_set(&pdev->dev,1);
if (err<0)
{
dev_err(&pdev->dev, "5T619 RTC: Pon=1 set 24h-mode error\n");
goto fail;
}
// setting the default year
// printk(KERN_INFO "PMU: %s Set default time\n", __func__);
pdata->time.tm_sec=0;
pdata->time.tm_min=0;
pdata->time.tm_hour=0;
pdata->time.tm_wday=6;
pdata->time.tm_mday=1;
pdata->time.tm_mon=1;
pdata->time.tm_year=2012;
pdata->time.tm_year -= os_ref_year;
if(ricoh619_rtc_valid_tm(&pdev->dev, &(pdata->time)) == 0)
{
tm.tm_sec = pdata->time.tm_sec;
tm.tm_min = pdata->time.tm_min;
tm.tm_hour = pdata->time.tm_hour;
tm.tm_wday= pdata->time.tm_wday;
tm.tm_mday= pdata->time.tm_mday;
tm.tm_mon = pdata->time.tm_mon-1;
tm.tm_year = pdata->time.tm_year;
}
else
{
// using the ricoh default time instead of board default time
dev_err(&pdev->dev, "board rtc default is erro\n");
tm.tm_sec = 0;
tm.tm_min = 0;
tm.tm_hour = 0;
tm.tm_wday = 4;
tm.tm_mday = 1;
tm.tm_mon = 0;
tm.tm_year = 70;
}
// set default alarm time
if (tm.tm_year >= 100)
buff[5] = tm.tm_year-100-1;
else
buff[5] = tm.tm_year-1;
buff[0] = tm.tm_sec;
buff[1] = tm.tm_min;
buff[2] = tm.tm_hour;
buff[3] = tm.tm_mday;
buff[4] = tm.tm_mon +1;
err = ricoh619_rtc_set_time(&pdev->dev, &tm);
if (err<0)
{
dev_err(&pdev->dev, "5t619 RTC:\n failed to set time\n");
goto fail;
}
convert_decimal_to_bcd(buff, sizeof(buff));
buff[3] |= 0x80; /* set DAL_EXT */
err = ricoh619_write_regs(&pdev->dev, rtc_alarm_y_sec, sizeof(buff), buff);
if (err<0)
printk( "\n unable to set alarm\n");
}
device_init_wakeup(&pdev->dev, 1);
// printk(KERN_INFO "PMU: %s register rtc device \n", __func__);
rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
&ricoh619_rtc_ops, THIS_MODULE);
// set interrupt and enable it
if(rtc->irq != -1) {
err = devm_request_threaded_irq(&pdev->dev,rtc->irq, NULL, ricoh619_rtc_irq,
IRQF_ONESHOT, "rtc_ricoh619", &pdev->dev);
if (err<0)
{
dev_err(&pdev->dev, "request IRQ:%d fail\n", rtc->irq);
rtc->irq = -1;
err = ricoh619_rtc_alarm_enable(&pdev->dev, 0);
if (err<0)
{
dev_err(&pdev->dev, "5T619 RTC: enable rtc alarm error\n");
goto fail;
}
}
else{
// enable wake
enable_irq_wake(rtc->irq);
// enable alarm_d
err = ricoh619_rtc_alarm_enable(&pdev->dev, Alarm_flag);
if (err<0)
{
dev_err(&pdev->dev, "failed rtc setup\n");
err = -EBUSY;
goto fail;
}
}
}
else
{
// system don't want to using alarm interrupt, so close it
err = ricoh619_rtc_alarm_enable(&pdev->dev, 0);
if (err<0)
{
dev_err(&pdev->dev, "5T619 RTC: Disable rtc alarm error\n");
goto fail;
}
dev_err(&pdev->dev, "ricoh619 interrupt is disabled\n");
}
printk(KERN_INFO "RICOH619 RTC Register Success\n");
ricoh619_read_regs(&pdev->dev, rtc_ctrl1, 1,&buff[0]);
ricoh619_read_regs(&pdev->dev, rtc_ctrl2, 1,&buff[1]);
// printk(KERN_INFO "0xAE:%x 0xAF:%x\n",buff[0],buff[1]);
return 0;
fail:
return err;
}
static int ricoh619_rtc_remove(struct platform_device *pdev)
{
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id ricoh619_rtc_dt_match[] = {
{ .compatible = "ricoh,ricoh619-rtc", },
{},
};
MODULE_DEVICE_TABLE(of, ricoh619_rtc_dt_match);
#endif
static struct platform_driver ricoh619_rtc_driver = {
.driver = {
.name = "ricoh619-rtc",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(ricoh619_rtc_dt_match),
},
.probe = ricoh619_rtc_probe,
.remove = ricoh619_rtc_remove,
};
static int __init ricoh619_rtc_init(void)
{
return platform_driver_register(&ricoh619_rtc_driver);
}
subsys_initcall_sync(ricoh619_rtc_init);
static void __exit ricoh619_rtc_exit(void)
{
platform_driver_unregister(&ricoh619_rtc_driver);
}
module_exit(ricoh619_rtc_exit);
MODULE_DESCRIPTION("RICOH RICOH619 RTC driver");
MODULE_ALIAS("platform:rtc_ricoh619");
MODULE_AUTHOR("zhangqing <zhangqing@rock-chips.com>");
MODULE_LICENSE("GPL");

View File

@@ -1,378 +0,0 @@
/*
* include/linux/mfd/ricoh619.h
*
* Core driver interface to access RICOH RC5T619 power management chip.
*
* Copyright (C) 2012-2013 RICOH COMPANY,LTD
*
* Based on code
* Copyright (C) 2011 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef __LINUX_MFD_RICOH619_H
#define __LINUX_MFD_RICOH619_H
#include <linux/mutex.h>
#include <linux/types.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
/* Maximum number of main interrupts */
#define MAX_INTERRUPT_MASKS 13
#define MAX_MAIN_INTERRUPT 7
#define MAX_GPEDGE_REG 2
/* Power control register */
#define RICOH619_PWR_WD 0x0B
#define RICOH619_PWR_WD_COUNT 0x0C
#define RICOH619_PWR_FUNC 0x0D
#define RICOH619_PWR_SLP_CNT 0x0E
#define RICOH619_PWR_REP_CNT 0x0F
#define RICOH619_PWR_ON_TIMSET 0x10
#define RICOH619_PWR_NOE_TIMSET 0x11
#define RICOH619_PWR_IRSEL 0x15
/* Interrupt enable register */
#define RICOH619_INT_EN_SYS 0x12
#define RICOH619_INT_EN_DCDC 0x40
#define RICOH619_INT_EN_RTC 0xAE
#define RICOH619_INT_EN_ADC1 0x88
#define RICOH619_INT_EN_ADC2 0x89
#define RICOH619_INT_EN_ADC3 0x8A
#define RICOH619_INT_EN_GPIO 0x94
#define RICOH619_INT_EN_GPIO2 0x94 // dummy
#define RICOH619_INT_MSK_CHGCTR 0xBE
#define RICOH619_INT_MSK_CHGSTS1 0xBF
#define RICOH619_INT_MSK_CHGSTS2 0xC0
#define RICOH619_INT_MSK_CHGERR 0xC1
#define RICOH619_INT_MSK_CHGEXTIF 0xD1
/* Interrupt select register */
#define RICOH619_PWR_IRSEL 0x15
#define RICOH619_CHG_CTRL_DETMOD1 0xCA
#define RICOH619_CHG_CTRL_DETMOD2 0xCB
#define RICOH619_CHG_STAT_DETMOD1 0xCC
#define RICOH619_CHG_STAT_DETMOD2 0xCD
#define RICOH619_CHG_STAT_DETMOD3 0xCE
/* interrupt status registers (monitor regs)*/
#define RICOH619_INTC_INTPOL 0x9C
#define RICOH619_INTC_INTEN 0x9D
#define RICOH619_INTC_INTMON 0x9E
#define RICOH619_INT_MON_SYS 0x14
#define RICOH619_INT_MON_DCDC 0x42
#define RICOH619_INT_MON_RTC 0xAF
#define RICOH619_INT_MON_CHGCTR 0xC6
#define RICOH619_INT_MON_CHGSTS1 0xC7
#define RICOH619_INT_MON_CHGSTS2 0xC8
#define RICOH619_INT_MON_CHGERR 0xC9
#define RICOH619_INT_MON_CHGEXTIF 0xD3
/* interrupt clearing registers */
#define RICOH619_INT_IR_SYS 0x13
#define RICOH619_INT_IR_DCDC 0x41
#define RICOH619_INT_IR_RTC 0xAF
#define RICOH619_INT_IR_ADCL 0x8C
#define RICOH619_INT_IR_ADCH 0x8D
#define RICOH619_INT_IR_ADCEND 0x8E
#define RICOH619_INT_IR_GPIOR 0x95
#define RICOH619_INT_IR_GPIOF 0x96
#define RICOH619_INT_IR_CHGCTR 0xC2
#define RICOH619_INT_IR_CHGSTS1 0xC3
#define RICOH619_INT_IR_CHGSTS2 0xC4
#define RICOH619_INT_IR_CHGERR 0xC5
#define RICOH619_INT_IR_CHGEXTIF 0xD2
/* GPIO register base address */
#define RICOH619_GPIO_IOSEL 0x90
#define RICOH619_GPIO_IOOUT 0x91
#define RICOH619_GPIO_GPEDGE1 0x92
#define RICOH619_GPIO_GPEDGE2 0x93
//#define RICOH619_GPIO_EN_GPIR 0x94
//#define RICOH619_GPIO_IR_GPR 0x95
//#define RICOH619_GPIO_IR_GPF 0x96
#define RICOH619_GPIO_MON_IOIN 0x97
#define RICOH619_GPIO_LED_FUNC 0x98
#define RICOH619_REG_BANKSEL 0xFF
/* Charger Control register */
#define RICOH619_CHG_CTL1 0xB3
#define TIMSET_REG 0xB9
/* ADC Control register */
#define RICOH619_ADC_CNT1 0x64
#define RICOH619_ADC_CNT2 0x65
#define RICOH619_ADC_CNT3 0x66
#define RICOH619_ADC_VADP_THL 0x7C
#define RICOH619_ADC_VSYS_THL 0x80
#define RICOH619_FG_CTRL 0xE0
#define RICOH619_PSWR 0x07
#define RICOH_DC1_SLOT 0x16
#define RICOH_DC2_SLOT 0x17
#define RICOH_DC3_SLOT 0x18
#define RICOH_DC4_SLOT 0x19
#define RICOH_DC5_SLOT 0x1a
#define RICOH_LDO1_SLOT 0x1b
#define RICOH_LDO2_SLOT 0x1c
#define RICOH_LDO3_SLOT 0x1d
#define RICOH_LDO4_SLOT 0x1e
#define RICOH_LDO5_SLOT 0x1f
#define RICOH_LDO6_SLOT 0x20
#define RICOH_LDO7_SLOT 0x21
#define RICOH_LDO8_SLOT 0x22
#define RICOH_LDO9_SLOT 0x23
#define RICOH_LDO10_SLOT 0x24
#define RICOH619_NUM_REGULATOR 17
/* RICOH619 IRQ definitions */
enum {
RICOH619_IRQ_POWER_ON,
RICOH619_IRQ_EXTIN,
RICOH619_IRQ_PRE_VINDT,
RICOH619_IRQ_PREOT,
RICOH619_IRQ_POWER_OFF,
RICOH619_IRQ_NOE_OFF,
RICOH619_IRQ_WD,
RICOH619_IRQ_CLK_STP,
RICOH619_IRQ_DC1LIM,
RICOH619_IRQ_DC2LIM,
RICOH619_IRQ_DC3LIM,
RICOH619_IRQ_DC4LIM,
RICOH619_IRQ_DC5LIM,
RICOH619_IRQ_ILIMLIR,
RICOH619_IRQ_VBATLIR,
RICOH619_IRQ_VADPLIR,
RICOH619_IRQ_VUSBLIR,
RICOH619_IRQ_VSYSLIR,
RICOH619_IRQ_VTHMLIR,
RICOH619_IRQ_AIN1LIR,
RICOH619_IRQ_AIN0LIR,
RICOH619_IRQ_ILIMHIR,
RICOH619_IRQ_VBATHIR,
RICOH619_IRQ_VADPHIR,
RICOH619_IRQ_VUSBHIR,
RICOH619_IRQ_VSYSHIR,
RICOH619_IRQ_VTHMHIR,
RICOH619_IRQ_AIN1HIR,
RICOH619_IRQ_AIN0HIR,
RICOH619_IRQ_ADC_ENDIR,
RICOH619_IRQ_GPIO0,
RICOH619_IRQ_GPIO1,
RICOH619_IRQ_GPIO2,
RICOH619_IRQ_GPIO3,
RICOH619_IRQ_GPIO4,
RICOH619_IRQ_CTC,
RICOH619_IRQ_DALE,
RICOH619_IRQ_FVADPDETSINT,
RICOH619_IRQ_FVUSBDETSINT,
RICOH619_IRQ_FVADPLVSINT,
RICOH619_IRQ_FVUSBLVSINT,
RICOH619_IRQ_FWVADPSINT,
RICOH619_IRQ_FWVUSBSINT,
RICOH619_IRQ_FONCHGINT,
RICOH619_IRQ_FCHGCMPINT,
RICOH619_IRQ_FBATOPENINT,
RICOH619_IRQ_FSLPMODEINT,
RICOH619_IRQ_FBTEMPJTA1INT,
RICOH619_IRQ_FBTEMPJTA2INT,
RICOH619_IRQ_FBTEMPJTA3INT,
RICOH619_IRQ_FBTEMPJTA4INT,
RICOH619_IRQ_FCURTERMINT,
RICOH619_IRQ_FVOLTERMINT,
RICOH619_IRQ_FICRVSINT,
RICOH619_IRQ_FPOOR_CHGCURINT,
RICOH619_IRQ_FOSCFDETINT1,
RICOH619_IRQ_FOSCFDETINT2,
RICOH619_IRQ_FOSCFDETINT3,
RICOH619_IRQ_FOSCMDETINT,
RICOH619_IRQ_FDIEOFFINT,
RICOH619_IRQ_FDIEERRINT,
RICOH619_IRQ_FBTEMPERRINT,
RICOH619_IRQ_FVBATOVINT,
RICOH619_IRQ_FTTIMOVINT,
RICOH619_IRQ_FRTIMOVINT,
RICOH619_IRQ_FVADPOVSINT,
RICOH619_IRQ_FVUSBOVSINT,
RICOH619_IRQ_FGCDET,
RICOH619_IRQ_FPCDET,
RICOH619_IRQ_FWARN_ADP,
/* Should be last entry */
RICOH619_NR_IRQS,
};
/* Ricoh619 gpio definitions */
enum {
RICOH619_GPIO0,
RICOH619_GPIO1,
RICOH619_GPIO2,
RICOH619_GPIO3,
RICOH619_GPIO4,
RICOH619_NR_GPIO,
};
enum ricoh619_sleep_control_id {
RICOH619_DS_DC1,
RICOH619_DS_DC2,
RICOH619_DS_DC3,
RICOH619_DS_DC4,
RICOH619_DS_DC5,
RICOH619_DS_LDO1,
RICOH619_DS_LDO2,
RICOH619_DS_LDO3,
RICOH619_DS_LDO4,
RICOH619_DS_LDO5,
RICOH619_DS_LDO6,
RICOH619_DS_LDO7,
RICOH619_DS_LDO8,
RICOH619_DS_LDO9,
RICOH619_DS_LDO10,
RICOH619_DS_LDORTC1,
RICOH619_DS_LDORTC2,
RICOH619_DS_PSO0,
RICOH619_DS_PSO1,
RICOH619_DS_PSO2,
RICOH619_DS_PSO3,
RICOH619_DS_PSO4,
};
struct ricoh619_subdev_info {
int id;
const char *name;
void *platform_data;
};
/*
struct ricoh619_rtc_platform_data {
int irq;
struct rtc_time time;
};
*/
struct ricoh619_gpio_init_data {
unsigned output_mode_en:1; /* Enable output mode during init */
unsigned output_val:1; /* Output value if it is in output mode */
unsigned init_apply:1; /* Apply init data on configuring gpios*/
unsigned led_mode:1; /* Select LED mode during init */
unsigned led_func:1; /* Set LED function if LED mode is 1 */
};
struct ricoh619 {
struct device *dev;
struct i2c_client *client;
struct mutex io_lock;
int gpio_base;
struct gpio_chip gpio_chip;
int irq_base;
// struct irq_chip irq_chip;
int chip_irq;
struct mutex irq_lock;
unsigned long group_irq_en[MAX_MAIN_INTERRUPT];
/* For main interrupt bits in INTC */
u8 intc_inten_cache;
u8 intc_inten_reg;
/* For group interrupt bits and address */
u8 irq_en_cache[MAX_INTERRUPT_MASKS];
u8 irq_en_reg[MAX_INTERRUPT_MASKS];
/* For gpio edge */
u8 gpedge_cache[MAX_GPEDGE_REG];
u8 gpedge_reg[MAX_GPEDGE_REG];
int bank_num;
struct irq_domain *irq_domain;
int dc_det;
};
struct ricoh619_platform_data {
int num_subdevs;
struct ricoh619_subdev_info *subdevs;
int (*init_port)(int irq_num); // Init GPIO for IRQ pin
int gpio_base;
int irq_base;
struct ricoh619_gpio_init_data *gpio_init_data;
int num_gpioinit_data;
bool enable_shutdown_pin;
bool pm_off;
struct regulator_init_data *reg_init_data[RICOH619_NUM_REGULATOR];
int irq_gpio;
int pmic_sleep_gpio; /* */
int dc_det;
bool pmic_sleep;
};
/* ==================================== */
/* RICOH619 Power_Key device data */
/* ==================================== */
struct ricoh619_pwrkey_platform_data {
int irq;
unsigned delay_ms;
};
extern int ricoh619_pwrkey_wakeup;
extern struct ricoh619 *g_ricoh619;
/* ==================================== */
/* RICOH619 battery device data */
/* ==================================== */
extern int g_soc;
extern int g_fg_on_mode;
extern int ricoh619_read(struct device *dev, uint8_t reg, uint8_t *val);
extern int ricoh619_read_bank1(struct device *dev, uint8_t reg, uint8_t *val);
extern int ricoh619_bulk_reads(struct device *dev, u8 reg, u8 count,
uint8_t *val);
extern int ricoh619_bulk_reads_bank1(struct device *dev, u8 reg, u8 count,
uint8_t *val);
extern int ricoh619_write(struct device *dev, u8 reg, uint8_t val);
extern int ricoh619_write_bank1(struct device *dev, u8 reg, uint8_t val);
extern int ricoh619_bulk_writes(struct device *dev, u8 reg, u8 count,
uint8_t *val);
extern int ricoh619_bulk_writes_bank1(struct device *dev, u8 reg, u8 count,
uint8_t *val);
extern int ricoh619_set_bits(struct device *dev, u8 reg, uint8_t bit_mask);
extern int ricoh619_clr_bits(struct device *dev, u8 reg, uint8_t bit_mask);
extern int ricoh619_update(struct device *dev, u8 reg, uint8_t val,
uint8_t mask);
extern int ricoh619_update_bank1(struct device *dev, u8 reg, uint8_t val,
uint8_t mask);
extern int ricoh619_irq_init(struct ricoh619 *ricoh619, int irq, struct ricoh619_platform_data *pdata);
extern int ricoh619_irq_exit(struct ricoh619 *ricoh619);
#endif

View File

@@ -1,153 +0,0 @@
/*
* include/linux/power/ricoh619_battery.h
*
* RICOH RC5T619 Charger Driver
*
* Copyright (C) 2012-2013 RICOH COMPANY,LTD
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LINUX_POWER_RICOH619_H_
#define __LINUX_POWER_RICOH619_H_
/* #include <linux/power_supply.h> */
/* #include <linux/types.h> */
#if 0
#define RICOH_FG_DBG(fmt, args...) printk( "RICOH_FG_DBG:\t"fmt, ##args)
#else
#define RICOH_FG_DBG(fmt, args...) {while(0);}
#endif
/* Defined battery information */
#define ADC_VDD_MV 2800
#define MIN_VOLTAGE 3100
#define MAX_VOLTAGE 4200
#define B_VALUE 3435
/* 619 Register information */
/* bank 0 */
#define PSWR_REG 0x07
#define VINDAC_REG 0x03
/* for ADC */
#define INTEN_REG 0x9D
#define EN_ADCIR3_REG 0x8A
#define ADCCNT3_REG 0x66
#define VBATDATAH_REG 0x6A
#define VBATDATAL_REG 0x6B
#define VSYSDATAH_REG 0x70
#define VSYSDATAL_REG 0x71
#define CHGCTL1_REG 0xB3
#define REGISET1_REG 0xB6
#define REGISET2_REG 0xB7
#define CHGISET_REG 0xB8
#define TIMSET_REG 0xB9
#define BATSET1_REG 0xBA
#define BATSET2_REG 0xBB
#define CHGSTATE_REG 0xBD
#define FG_CTRL_REG 0xE0
#define SOC_REG 0xE1
#define RE_CAP_H_REG 0xE2
#define RE_CAP_L_REG 0xE3
#define FA_CAP_H_REG 0xE4
#define FA_CAP_L_REG 0xE5
#define TT_EMPTY_H_REG 0xE7
#define TT_EMPTY_L_REG 0xE8
#define TT_FULL_H_REG 0xE9
#define TT_FULL_L_REG 0xEA
#define VOLTAGE_1_REG 0xEB
#define VOLTAGE_2_REG 0xEC
#define TEMP_1_REG 0xED
#define TEMP_2_REG 0xEE
#define CC_CTRL_REG 0xEF
#define CC_SUMREG3_REG 0xF3
#define CC_SUMREG2_REG 0xF4
#define CC_SUMREG1_REG 0xF5
#define CC_SUMREG0_REG 0xF6
#define CC_AVERAGE1_REG 0xFB
#define CC_AVERAGE0_REG 0xFC
/* bank 1 */
/* Top address for battery initial setting */
#define BAT_INIT_TOP_REG 0xBC
#define TEMP_GAIN_H_REG 0xD6
#define TEMP_OFF_H_REG 0xD8
#define BAT_REL_SEL_REG 0xDA
#define BAT_TA_SEL_REG 0xDB
/**************************/
/* detailed status in CHGSTATE (0xBD) */
enum ChargeState {
CHG_STATE_CHG_OFF = 0,
CHG_STATE_CHG_READY_VADP,
CHG_STATE_CHG_TRICKLE,
CHG_STATE_CHG_RAPID,
CHG_STATE_CHG_COMPLETE,
CHG_STATE_SUSPEND,
CHG_STATE_VCHG_OVER_VOL,
CHG_STATE_BAT_ERROR,
CHG_STATE_NO_BAT,
CHG_STATE_BAT_OVER_VOL,
CHG_STATE_BAT_TEMP_ERR,
CHG_STATE_DIE_ERR,
CHG_STATE_DIE_SHUTDOWN,
CHG_STATE_NO_BAT2,
CHG_STATE_CHG_READY_VUSB,
};
enum SupplyState {
SUPPLY_STATE_BAT = 0,
SUPPLY_STATE_ADP,
SUPPLY_STATE_USB,
} ;
struct ricoh619_battery_type_data {
int ch_vfchg;
int ch_vrchg;
int ch_vbatovset;
int ch_ichg;
int ch_icchg;
int ch_ilim_adp;
int ch_ilim_usb;
int fg_target_vsys;
int fg_target_ibat;
int fg_poff_vbat;
int jt_en;
int jt_hw_sw;
int jt_temp_h;
int jt_temp_l;
int jt_vfchg_h;
int jt_vfchg_l;
int jt_ichg_h;
int jt_ichg_l;
};
#define BATTERY_TYPE_NUM 1
struct ricoh619_battery_platform_data {
int irq;
int alarm_vol_mv;
int multiple;
unsigned monitor_time;
struct ricoh619_battery_type_data type[BATTERY_TYPE_NUM];
};
extern struct ricoh619 *g_ricoh619;
#endif

View File

@@ -1,72 +0,0 @@
/*
* linux/regulator/ricoh619-regulator.h
*
* Regulator driver for RICOH619 power management chip.
*
* Copyright (C) 2012-2013 RICOH COMPANY,LTD
*
* Based on code
* Copyright (C) 2011 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LINUX_REGULATOR_RICOH619_H
#define __LINUX_REGULATOR_RICOH619_H
#include <linux/regulator/machine.h>
#include <linux/regulator/driver.h>
#define ricoh619_rails(_name) "RICOH619_"#_name
/* RICHOH Regulator IDs */
enum regulator_id {
RICOH619_ID_DC1,
RICOH619_ID_DC2,
RICOH619_ID_DC3,
RICOH619_ID_DC4,
RICOH619_ID_DC5,
RICOH619_ID_LDO1,
RICOH619_ID_LDO2,
RICOH619_ID_LDO3,
RICOH619_ID_LDO4,
RICOH619_ID_LDO5,
RICOH619_ID_LDO6,
RICOH619_ID_LDO7,
RICOH619_ID_LDO8,
RICOH619_ID_LDO9,
RICOH619_ID_LDO10,
RICOH619_ID_LDORTC1,
RICOH619_ID_LDORTC2,
};
struct ricoh619_regulator_platform_data {
struct regulator_init_data regulator;
int init_uV;
unsigned init_enable:1;
unsigned init_apply:1;
int sleep_uV;
int sleep_slots;
unsigned long ext_pwr_req;
unsigned long flags;
};
extern int ricoh619_regulator_enable_eco_mode(struct regulator_dev *rdev);
extern int ricoh619_regulator_disable_eco_mode(struct regulator_dev *rdev);
extern int ricoh619_regulator_enable_eco_slp_mode(struct regulator_dev *rdev);
extern int ricoh619_regulator_disable_eco_slp_mode(struct regulator_dev *rdev);
#endif

View File

@@ -1,59 +0,0 @@
/*
* include/linux/rtc/rtc-ricoh619.h
*
* Real time clock driver for RICOH R5T619 power management chip.
*
* Copyright (C) 2012-2013 RICOH COMPANY,LTD
*
* Based on code
* Copyright (C) 2011 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* you should have received a copy of the gnu general public license
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LINUX_RTC_RICOH619_H_
#define __LINUX_RTC_RICOH619_H_
#include <linux/rtc.h>
#define rtc_ctrl1 0xAE
#define rtc_ctrl2 0xAF
#define rtc_seconds_reg 0xA0
#define rtc_alarm_y_sec 0xA8
#define rtc_adjust 0xA7
#define rtc_month_reg 0xA5
#define rtc_mday_reg 0xA4
#define rtc_dal_month_reg 0xAC
/*
linux rtc driver refers 1900 as base year in many calculations.
(e.g. refer drivers/rtc/rtc-lib.c)
*/
#define os_ref_year 1900
/*
pmu rtc have only 2 nibbles to store year information, so using an
offset of 100 to set the base year as 2000 for our driver.
*/
struct ricoh619_rtc_platform_data {
int irq;
struct rtc_time time;
};
#endif