summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorZhou Jingyu <b02241@freescale.com>2010-03-11 10:08:32 +0800
committerAlejandro Gonzalez <alex.gonzalez@digi.com>2010-05-25 11:17:21 +0200
commit262ad3d751730da9801fdf450c108d57bbe107fd (patch)
treea2fe61f38151cdc65859df262b1a7c68dae15a34 /arch
parentb75491caed15403f20612902bb9ed6b6782178fe (diff)
ENGR00121496: mx23 battery driver restructure
mx23 battery driver restructure Signed-off-by: Zhou Jingyu <Jingyu.Zhou@freescale.com> Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/configs/imx23evk_defconfig11
-rw-r--r--arch/arm/mach-mx23/device.c87
-rw-r--r--arch/arm/mach-mx23/include/mach/irqs.h6
-rw-r--r--arch/arm/plat-mxs/Makefile3
-rw-r--r--arch/arm/plat-mxs/icoll.c27
-rw-r--r--arch/arm/plat-mxs/include/mach/ddi_bc.h1
-rw-r--r--arch/arm/plat-mxs/include/mach/irqs.h5
-rw-r--r--arch/arm/plat-mxs/usb_common.c12
8 files changed, 146 insertions, 6 deletions
diff --git a/arch/arm/configs/imx23evk_defconfig b/arch/arm/configs/imx23evk_defconfig
index 1b66a1b65676..5c646a45d8ca 100644
--- a/arch/arm/configs/imx23evk_defconfig
+++ b/arch/arm/configs/imx23evk_defconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.31
-# Wed Mar 10 21:57:59 2010
+# Mon Mar 15 09:38:37 2010
#
CONFIG_ARM=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -613,7 +613,14 @@ CONFIG_GPIOLIB=y
# SPI GPIO expanders:
#
# CONFIG_W1 is not set
-# CONFIG_POWER_SUPPLY is not set
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+# CONFIG_PDA_POWER is not set
+# CONFIG_BATTERY_DS2760 is not set
+# CONFIG_BATTERY_DS2782 is not set
+# CONFIG_BATTERY_BQ27x00 is not set
+# CONFIG_BATTERY_MAX17040 is not set
+CONFIG_BATTERY_MXS=y
# CONFIG_HWMON is not set
# CONFIG_THERMAL is not set
# CONFIG_THERMAL_HWMON is not set
diff --git a/arch/arm/mach-mx23/device.c b/arch/arm/mach-mx23/device.c
index 31f514b5266a..fc2ddc1a01ef 100644
--- a/arch/arm/mach-mx23/device.c
+++ b/arch/arm/mach-mx23/device.c
@@ -36,8 +36,10 @@
#include <mach/regs-lradc.h>
#include <mach/device.h>
#include <mach/dma.h>
+#include <mach/irqs.h>
#include <mach/lradc.h>
#include <mach/lcdif.h>
+#include <mach/ddi_bc.h>
#include "device.h"
#include "mx23_pins.h"
@@ -602,6 +604,89 @@ static void mx23_init_mmc(void)
}
#endif
+#if defined(CONFIG_BATTERY_MXS)
+/* battery info data */
+static ddi_bc_Cfg_t battery_data = {
+ .u32StateMachinePeriod = 100, /* ms */
+ .u16CurrentRampSlope = 75, /* mA/s */
+ .u16ConditioningThresholdVoltage = 2900, /* mV */
+ .u16ConditioningMaxVoltage = 3000, /* mV */
+ .u16ConditioningCurrent = 60, /* mA */
+ .u32ConditioningTimeout = 4*60*60*1000, /* ms (4 hours) */
+ .u16ChargingVoltage = 4200, /* mV */
+ /* FIXME: the current comparator could have h/w bugs in current
+ * detection through POWER_STS.CHRGSTS bit */
+ .u16ChargingCurrent = 600, /* mA 600 */
+ .u16ChargingThresholdCurrent = 60, /* mA 60 */
+ .u32ChargingTimeout = 4*60*60*1000,/* ms (4 hours) */
+ .u32TopOffPeriod = 30*60*1000, /* ms (30 minutes) */
+ .monitorDieTemp = 1, /* Monitor the die */
+ .u8DieTempHigh = 75, /* deg centigrade */
+ .u8DieTempLow = 65, /* deg centigrade */
+ .u16DieTempSafeCurrent = 0, /* mA */
+ .monitorBatteryTemp = 0, /* Monitor the battery*/
+ .u8BatteryTempChannel = 1, /* LRADC 1 */
+ .u16BatteryTempHigh = 642, /* Unknown units */
+ .u16BatteryTempLow = 497, /* Unknown units */
+ .u16BatteryTempSafeCurrent = 0, /* mA */
+};
+
+static struct resource battery_resource[] = {
+ {/* 0 */
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_VDD5V,
+ .end = IRQ_VDD5V,
+ },
+ {/* 1 */
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_DCDC4P2_BO,
+ .end = IRQ_DCDC4P2_BO,
+ },
+ {/* 2 */
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_BATT_BRNOUT,
+ .end = IRQ_BATT_BRNOUT,
+ },
+ {/* 3 */
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_VDDD_BRNOUT,
+ .end = IRQ_VDDD_BRNOUT,
+ },
+ {/* 4 */
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_VDD18_BRNOUT,
+ .end = IRQ_VDD18_BRNOUT,
+ },
+ {/* 5 */
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_VDDIO_BRNOUT,
+ .end = IRQ_VDDIO_BRNOUT,
+ },
+ {/* 6 */
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_VDD5V_DROOP,
+ .end = IRQ_VDD5V_DROOP,
+ },
+};
+
+static void mx23_init_battery(void)
+{
+ struct platform_device *pdev;
+ pdev = mxs_get_device("mxs-battery", 0);
+ if (pdev) {
+ pdev->resource = battery_resource,
+ pdev->num_resources = ARRAY_SIZE(battery_resource),
+ pdev->dev.platform_data = &battery_data;
+ mxs_add_device(pdev, 3);
+ }
+}
+#else
+static void mx23_init_battery(void)
+{
+}
+#endif
+
+
int __init mx23_device_init(void)
{
mx23_init_dma();
@@ -617,6 +702,8 @@ int __init mx23_device_init(void)
mx23_init_mmc();
mx23_init_lcdif();
mx23_init_pxp();
+ mx23_init_battery();
+
return 0;
}
diff --git a/arch/arm/mach-mx23/include/mach/irqs.h b/arch/arm/mach-mx23/include/mach/irqs.h
index dc4e578b0e34..5d5211b6e889 100644
--- a/arch/arm/mach-mx23/include/mach/irqs.h
+++ b/arch/arm/mach-mx23/include/mach/irqs.h
@@ -94,3 +94,9 @@
/* Hard disk IRQ is a GPMI attention IRQ */
#define IRQ_HARDDISK IRQ_GPMI_ATTENTION
+
+#ifndef __ASSEMBLY__
+void mxs_set_irq_fiq(unsigned int irq, unsigned int type);
+void mxs_enable_fiq_functionality(int enable);
+#endif
+
diff --git a/arch/arm/plat-mxs/Makefile b/arch/arm/plat-mxs/Makefile
index fa25e5e51a49..95b4c05415e5 100644
--- a/arch/arm/plat-mxs/Makefile
+++ b/arch/arm/plat-mxs/Makefile
@@ -11,7 +11,8 @@ obj-$(CONFIG_GENERIC_GPIO) += gpio.o
obj-$(CONFIG_MXS_ICOLL) += icoll.o
obj-$(CONFIG_MXS_DMA_ENGINE) += dmaengine.o dma-apbh.o dma-apbx.o
-obj-$(CONFIG_ARCH_MX28) += usb_common.o utmixc.o
+obj-$(CONFIG_ARCH_MX28) += utmixc.o
+obj-$(CONFIG_ARCH_MXS) += usb_common.o
obj-$(CONFIG_MXS_LRADC) += lradc.o
# Power Management
diff --git a/arch/arm/plat-mxs/icoll.c b/arch/arm/plat-mxs/icoll.c
index ef05e63d3dd1..bb4e4c12cb23 100644
--- a/arch/arm/plat-mxs/icoll.c
+++ b/arch/arm/plat-mxs/icoll.c
@@ -23,6 +23,7 @@
#include <mach/hardware.h>
#include <mach/device.h>
+#include <mach/irqs.h>
#include "regs-icoll.h"
@@ -106,3 +107,29 @@ void __init avic_init_irq(void __iomem *base, int nr_irqs)
/* Barrier */
(void)__raw_readl(g_icoll_base + HW_ICOLL_STAT);
}
+
+void mxs_set_irq_fiq(unsigned int irq, unsigned int type)
+{
+ if (type == 0)
+ __raw_writel(BM_ICOLL_INTERRUPTn_ENFIQ,
+ g_icoll_base +
+ HW_ICOLL_INTERRUPTn_CLR(irq));
+ else
+ __raw_writel(BM_ICOLL_INTERRUPTn_ENFIQ,
+ g_icoll_base +
+ HW_ICOLL_INTERRUPTn_SET(irq));
+}
+EXPORT_SYMBOL(mxs_set_irq_fiq);
+
+void mxs_enable_fiq_functionality(int enable)
+{
+ if (enable)
+ __raw_writel(BM_ICOLL_CTRL_FIQ_FINAL_ENABLE,
+ g_icoll_base + HW_ICOLL_CTRL_SET);
+ else
+ __raw_writel(BM_ICOLL_CTRL_FIQ_FINAL_ENABLE,
+ g_icoll_base + HW_ICOLL_CTRL_CLR);
+
+}
+EXPORT_SYMBOL(mxs_enable_fiq_functionality);
+
diff --git a/arch/arm/plat-mxs/include/mach/ddi_bc.h b/arch/arm/plat-mxs/include/mach/ddi_bc.h
index ceeed0c6ec46..21ca9217cdaa 100644
--- a/arch/arm/plat-mxs/include/mach/ddi_bc.h
+++ b/arch/arm/plat-mxs/include/mach/ddi_bc.h
@@ -708,6 +708,7 @@ ddi_bc_Status_t ddi_bc_ForceChargingToStart(void);
void fsl_enable_usb_plugindetect(void);
int fsl_is_usb_plugged(void);
+
/* End of file */
#endif /* _DDI_BC_H */
diff --git a/arch/arm/plat-mxs/include/mach/irqs.h b/arch/arm/plat-mxs/include/mach/irqs.h
index f2de0d22ad41..62165e12a60c 100644
--- a/arch/arm/plat-mxs/include/mach/irqs.h
+++ b/arch/arm/plat-mxs/include/mach/irqs.h
@@ -35,5 +35,10 @@ struct irq_ic_info {
#define __irq_ic_info_attr __attribute__((__section__(".irq_ic_info.array")))
extern struct irq_ic_info *current_irq_ic_info;
+
+void mxs_set_irq_fiq(unsigned int irq, unsigned int type);
+void mxs_enable_fiq_functionality(int enable);
+
#endif
+
#endif /* __ASM_ARCH_SYSTEM_H__ */
diff --git a/arch/arm/plat-mxs/usb_common.c b/arch/arm/plat-mxs/usb_common.c
index 0bc12d4f615d..b6f556866a52 100644
--- a/arch/arm/plat-mxs/usb_common.c
+++ b/arch/arm/plat-mxs/usb_common.c
@@ -44,9 +44,11 @@
#include <linux/usb/otg.h>
#include <linux/usb/fsl_xcvr.h>
#include <mach/arc_otg.h>
+#include <mach/hardware.h>
#include <linux/io.h>
#include "regs-usbphy.h"
+#ifdef CONFIG_ARCH_MX28
#define MXC_NUMBER_USB_TRANSCEIVER 6
struct fsl_xcvr_ops *g_xc_ops[MXC_NUMBER_USB_TRANSCEIVER] = { NULL };
@@ -376,15 +378,19 @@ int usb_host_wakeup_irq(struct device *wkup_dev)
return 0;
}
EXPORT_SYMBOL(usb_host_wakeup_irq);
-
+#endif
void usb_host_set_wakeup(struct device *wkup_dev, bool para)
{
}
EXPORT_SYMBOL(usb_host_set_wakeup);
+#ifdef CONFIG_ARCH_MX28
+#define USBPHY_PHYS_ADDR USBPHY0_PHYS_ADDR
+#endif
+
int fsl_is_usb_plugged(void)
{
- return __raw_readl(REGS_USBPHY_BASE + HW_USBPHY_STATUS) & \
+ return __raw_readl(IO_ADDRESS(USBPHY_PHYS_ADDR) + HW_USBPHY_STATUS) & \
BM_USBPHY_STATUS_DEVPLUGIN_STATUS;
}
EXPORT_SYMBOL(fsl_is_usb_plugged);
@@ -392,7 +398,7 @@ EXPORT_SYMBOL(fsl_is_usb_plugged);
void fsl_enable_usb_plugindetect(void)
{
__raw_writel(BM_USBPHY_CTRL_ENDEVPLUGINDETECT,
- REGS_USBPHY_BASE + HW_USBPHY_CTRL_SET);
+ IO_ADDRESS(USBPHY_PHYS_ADDR) + HW_USBPHY_CTRL_SET);
}
EXPORT_SYMBOL(fsl_enable_usb_plugindetect);