Commit 70ac5516 authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/home/rmk/linux-2.6-arm

parents 7f729ccf bd5d080a
...@@ -702,6 +702,8 @@ menu "Device Drivers" ...@@ -702,6 +702,8 @@ menu "Device Drivers"
source "drivers/base/Kconfig" source "drivers/base/Kconfig"
source "drivers/connector/Kconfig"
if ALIGNMENT_TRAP if ALIGNMENT_TRAP
source "drivers/mtd/Kconfig" source "drivers/mtd/Kconfig"
endif endif
......
...@@ -623,8 +623,6 @@ static int locomo_resume(struct platform_device *dev) ...@@ -623,8 +623,6 @@ static int locomo_resume(struct platform_device *dev)
locomo_writel(0x1, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KCMD); locomo_writel(0x1, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KCMD);
spin_unlock_irqrestore(&lchip->lock, flags); spin_unlock_irqrestore(&lchip->lock, flags);
dev->power.saved_state = NULL;
kfree(save); kfree(save);
return 0; return 0;
...@@ -775,7 +773,7 @@ static int locomo_probe(struct platform_device *dev) ...@@ -775,7 +773,7 @@ static int locomo_probe(struct platform_device *dev)
static int locomo_remove(struct platform_device *dev) static int locomo_remove(struct platform_device *dev)
{ {
struct locomo *lchip = platform__get_drvdata(dev); struct locomo *lchip = platform_get_drvdata(dev);
if (lchip) { if (lchip) {
__locomo_remove(lchip); __locomo_remove(lchip);
......
...@@ -153,7 +153,7 @@ int __init scoop_probe(struct platform_device *pdev) ...@@ -153,7 +153,7 @@ int __init scoop_probe(struct platform_device *pdev)
printk("Sharp Scoop Device found at 0x%08x -> 0x%08x\n",(unsigned int)mem->start,(unsigned int)devptr->base); printk("Sharp Scoop Device found at 0x%08x -> 0x%08x\n",(unsigned int)mem->start,(unsigned int)devptr->base);
SCOOP_REG(devptr->base, SCOOP_MCR) = 0x0140; SCOOP_REG(devptr->base, SCOOP_MCR) = 0x0140;
reset_scoop(dev); reset_scoop(&pdev->dev);
SCOOP_REG(devptr->base, SCOOP_GPCR) = inf->io_dir & 0xffff; SCOOP_REG(devptr->base, SCOOP_GPCR) = inf->io_dir & 0xffff;
SCOOP_REG(devptr->base, SCOOP_GPWR) = inf->io_out & 0xffff; SCOOP_REG(devptr->base, SCOOP_GPWR) = inf->io_out & 0xffff;
......
...@@ -256,9 +256,7 @@ void __cpuexit cpu_die(void) ...@@ -256,9 +256,7 @@ void __cpuexit cpu_die(void)
asmlinkage void __cpuinit secondary_start_kernel(void) asmlinkage void __cpuinit secondary_start_kernel(void)
{ {
struct mm_struct *mm = &init_mm; struct mm_struct *mm = &init_mm;
unsigned int cpu; unsigned int cpu = smp_processor_id();
cpu = smp_processor_id();
printk("CPU%u: Booted secondary processor\n", cpu); printk("CPU%u: Booted secondary processor\n", cpu);
......
...@@ -132,14 +132,14 @@ void __init footbridge_init_irq(void) ...@@ -132,14 +132,14 @@ void __init footbridge_init_irq(void)
static struct map_desc fb_common_io_desc[] __initdata = { static struct map_desc fb_common_io_desc[] __initdata = {
{ {
.virtual = ARMCSR_BASE, .virtual = ARMCSR_BASE,
.pfn = DC21285_ARMCSR_BASE, .pfn = __phys_to_pfn(DC21285_ARMCSR_BASE),
.length = ARMCSR_SIZE, .length = ARMCSR_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
}, { }, {
.virtual = XBUS_BASE, .virtual = XBUS_BASE,
.pfn = __phys_to_pfn(0x40000000), .pfn = __phys_to_pfn(0x40000000),
.length = XBUS_SIZE, .length = XBUS_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
} }
}; };
...@@ -153,28 +153,28 @@ static struct map_desc ebsa285_host_io_desc[] __initdata = { ...@@ -153,28 +153,28 @@ static struct map_desc ebsa285_host_io_desc[] __initdata = {
.virtual = PCIMEM_BASE, .virtual = PCIMEM_BASE,
.pfn = __phys_to_pfn(DC21285_PCI_MEM), .pfn = __phys_to_pfn(DC21285_PCI_MEM),
.length = PCIMEM_SIZE, .length = PCIMEM_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
}, { }, {
.virtual = PCICFG0_BASE, .virtual = PCICFG0_BASE,
.pfn = __phys_to_pfn(DC21285_PCI_TYPE_0_CONFIG), .pfn = __phys_to_pfn(DC21285_PCI_TYPE_0_CONFIG),
.length = PCICFG0_SIZE, .length = PCICFG0_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
}, { }, {
.virtual = PCICFG1_BASE, .virtual = PCICFG1_BASE,
.pfn = __phys_to_pfn(DC21285_PCI_TYPE_1_CONFIG), .pfn = __phys_to_pfn(DC21285_PCI_TYPE_1_CONFIG),
.length = PCICFG1_SIZE, .length = PCICFG1_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
}, { }, {
.virtual = PCIIACK_BASE, .virtual = PCIIACK_BASE,
.pfn = __phys_to_pfn(DC21285_PCI_IACK), .pfn = __phys_to_pfn(DC21285_PCI_IACK),
.length = PCIIACK_SIZE, .length = PCIIACK_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
}, { }, {
.virtual = PCIO_BASE, .virtual = PCIO_BASE,
.pfn = __phys_to_pfn(DC21285_PCI_IO), .pfn = __phys_to_pfn(DC21285_PCI_IO),
.length = PCIO_SIZE, .length = PCIO_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
} },
#endif #endif
}; };
...@@ -187,13 +187,13 @@ static struct map_desc co285_io_desc[] __initdata = { ...@@ -187,13 +187,13 @@ static struct map_desc co285_io_desc[] __initdata = {
.virtual = PCIO_BASE, .virtual = PCIO_BASE,
.pfn = __phys_to_pfn(DC21285_PCI_IO), .pfn = __phys_to_pfn(DC21285_PCI_IO),
.length = PCIO_SIZE, .length = PCIO_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
}, { }, {
.virtual = PCIMEM_BASE, .virtual = PCIMEM_BASE,
.pfn = __phys_to_pfn(DC21285_PCI_MEM), .pfn = __phys_to_pfn(DC21285_PCI_MEM),
.length = PCIMEM_SIZE, .length = PCIMEM_SIZE,
.type = MT_DEVICE .type = MT_DEVICE,
} },
#endif #endif
}; };
......
...@@ -72,6 +72,12 @@ config MACH_HUSKY ...@@ -72,6 +72,12 @@ config MACH_HUSKY
depends PXA_SHARPSL_25x depends PXA_SHARPSL_25x
select PXA_SHARP_C7xx select PXA_SHARP_C7xx
config MACH_AKITA
bool "Enable Sharp SL-1000 (Akita) Support"
depends PXA_SHARPSL_27x
select PXA_SHARP_Cxx00
select MACH_SPITZ
config MACH_SPITZ config MACH_SPITZ
bool "Enable Sharp Zaurus SL-3000 (Spitz) Support" bool "Enable Sharp Zaurus SL-3000 (Spitz) Support"
depends PXA_SHARPSL_27x depends PXA_SHARPSL_27x
......
...@@ -11,8 +11,9 @@ obj-$(CONFIG_PXA27x) += pxa27x.o ...@@ -11,8 +11,9 @@ obj-$(CONFIG_PXA27x) += pxa27x.o
obj-$(CONFIG_ARCH_LUBBOCK) += lubbock.o obj-$(CONFIG_ARCH_LUBBOCK) += lubbock.o
obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o
obj-$(CONFIG_ARCH_PXA_IDP) += idp.o obj-$(CONFIG_ARCH_PXA_IDP) += idp.o
obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o corgi_ssp.o corgi_lcd.o obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o corgi_pm.o
obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o corgi_ssp.o corgi_lcd.o obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o spitz_pm.o
obj-$(CONFIG_MACH_AKITA) += akita-ioexp.o
obj-$(CONFIG_MACH_POODLE) += poodle.o obj-$(CONFIG_MACH_POODLE) += poodle.o
obj-$(CONFIG_MACH_TOSA) += tosa.o obj-$(CONFIG_MACH_TOSA) += tosa.o
......
/*
* Support for the Extra GPIOs on the Sharp SL-C1000 (Akita)
* (uses a Maxim MAX7310 8 Port IO Expander)
*
* Copyright 2005 Openedhand Ltd.
*
* Author: Richard Purdie <richard@openedhand.com>
*
* 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.
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <asm/arch/akita.h>
/* MAX7310 Regiser Map */
#define MAX7310_INPUT 0x00
#define MAX7310_OUTPUT 0x01
#define MAX7310_POLINV 0x02
#define MAX7310_IODIR 0x03 /* 1 = Input, 0 = Output */
#define MAX7310_TIMEOUT 0x04
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x18, I2C_CLIENT_END };
/* I2C Magic */
I2C_CLIENT_INSMOD;
static int max7310_write(struct i2c_client *client, int address, int data);
static struct i2c_client max7310_template;
static void akita_ioexp_work(void *private_);
static struct device *akita_ioexp_device;
static unsigned char ioexp_output_value = AKITA_IOEXP_IO_OUT;
DECLARE_WORK(akita_ioexp, akita_ioexp_work, NULL);
/*
* MAX7310 Access
*/
static int max7310_config(struct device *dev, int iomode, int polarity)
{
int ret;
struct i2c_client *client = to_i2c_client(dev);
ret = max7310_write(client, MAX7310_POLINV, polarity);
if (ret < 0)
return ret;
ret = max7310_write(client, MAX7310_IODIR, iomode);
return ret;
}
static int max7310_set_ouputs(struct device *dev, int outputs)
{
struct i2c_client *client = to_i2c_client(dev);
return max7310_write(client, MAX7310_OUTPUT, outputs);
}
/*
* I2C Functions
*/
static int max7310_write(struct i2c_client *client, int address, int value)
{
u8 data[2];
data[0] = address & 0xff;
data[1] = value & 0xff;
if (i2c_master_send(client, data, 2) == 2)
return 0;
return -1;
}
static int max7310_detect(struct i2c_adapter *adapter, int address, int kind)
{
struct i2c_client *new_client;
int err;
if (!(new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
return -ENOMEM;
max7310_template.adapter = adapter;
max7310_template.addr = address;
memcpy(new_client, &max7310_template, sizeof(struct i2c_client));
if ((err = i2c_attach_client(new_client))) {
kfree(new_client);
return err;
}
max7310_config(&new_client->dev, AKITA_IOEXP_IO_DIR, 0);
akita_ioexp_device = &new_client->dev;
schedule_work(&akita_ioexp);
return 0;
}
static int max7310_attach_adapter(struct i2c_adapter *adapter)
{
return i2c_probe(adapter, &addr_data, max7310_detect);
}
static int max7310_detach_client(struct i2c_client *client)
{
int err;
akita_ioexp_device = NULL;
if ((err = i2c_detach_client(client)))
return err;
kfree(client);
return 0;
}
static struct i2c_driver max7310_i2c_driver = {
.owner = THIS_MODULE,
.name = "akita-max7310",
.id = I2C_DRIVERID_AKITAIOEXP,
.flags = I2C_DF_NOTIFY,
.attach_adapter = max7310_attach_adapter,
.detach_client = max7310_detach_client,
};
static struct i2c_client max7310_template = {
name: "akita-max7310",
flags: I2C_CLIENT_ALLOW_USE,
driver: &max7310_i2c_driver,
};
void akita_set_ioexp(struct device *dev, unsigned char bit)
{
ioexp_output_value |= bit;
if (akita_ioexp_device)
schedule_work(&akita_ioexp);
return;
}
void akita_reset_ioexp(struct device *dev, unsigned char bit)
{
ioexp_output_value &= ~bit;
if (akita_ioexp_device)
schedule_work(&akita_ioexp);
return;
}
EXPORT_SYMBOL(akita_set_ioexp);
EXPORT_SYMBOL(akita_reset_ioexp);
static void akita_ioexp_work(void *private_)
{
if (akita_ioexp_device)
max7310_set_ouputs(akita_ioexp_device, ioexp_output_value);
}
#ifdef CONFIG_PM
static int akita_ioexp_suspend(struct platform_device *pdev, pm_message_t state)
{
flush_scheduled_work();
return 0;
}
static int akita_ioexp_resume(struct platform_device *pdev)
{
schedule_work(&akita_ioexp);
return 0;
}
#else
#define akita_ioexp_suspend NULL
#define akita_ioexp_resume NULL
#endif
static int __init akita_ioexp_probe(struct platform_device *pdev)
{
return i2c_add_driver(&max7310_i2c_driver);
}
static int akita_ioexp_remove(struct platform_device *pdev)
{
i2c_del_driver(&max7310_i2c_driver);
return 0;
}
static struct platform_driver akita_ioexp_driver = {
.probe = akita_ioexp_probe,
.remove = akita_ioexp_remove,
.suspend = akita_ioexp_suspend,
.resume = akita_ioexp_resume,
.driver = {
.name = "akita-ioexp",
},
};
static int __init akita_ioexp_init(void)
{
return platform_driver_register(&akita_ioexp_driver);
}
static void __exit akita_ioexp_exit(void)
{
platform_driver_unregister(&akita_ioexp_driver);
}
MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
MODULE_DESCRIPTION("Akita IO-Expander driver");
MODULE_LICENSE("GPL");
fs_initcall(akita_ioexp_init);
module_exit(akita_ioexp_exit);
/*
* Battery and Power Management code for the Sharp SL-C7xx
*
* Copyright (c) 2005 Richard Purdie
*
* 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.
*
*/
#include <linux/module.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <asm/apm.h>
#include <asm/irq.h>
#include <asm/mach-types.h>
#include <asm/hardware.h>
#include <asm/hardware/scoop.h>
#include <asm/arch/sharpsl.h>
#include <asm/arch/corgi.h>
#include <asm/arch/pxa-regs.h>
#include "sharpsl.h"
static void corgi_charger_init(void)
{
pxa_gpio_mode(CORGI_GPIO_ADC_TEMP_ON | GPIO_OUT);
pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT);
pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT);
pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN);
}
static void corgi_charge_led(int val)
{
if (val == SHARPSL_LED_ERROR) {
dev_dbg(sharpsl_pm.dev, "Charge LED Error\n");
} else if (val == SHARPSL_LED_ON) {
dev_dbg(sharpsl_pm.dev, "Charge LED On\n");
GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
} else {
dev_dbg(sharpsl_pm.dev, "Charge LED Off\n");
GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
}
}
static void corgi_measure_temp(int on)
{
if (on)
GPSR(CORGI_GPIO_ADC_TEMP_ON) = GPIO_bit(CORGI_GPIO_ADC_TEMP_ON);
else
GPCR(CORGI_GPIO_ADC_TEMP_ON) = GPIO_bit(CORGI_GPIO_ADC_TEMP_ON);
}
static void corgi_charge(int on)
{
if (on) {
if (machine_is_corgi() && (sharpsl_pm.flags & SHARPSL_SUSPENDED)) {
GPCR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON);
GPSR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN);
} else {
GPSR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON);
GPCR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN);
}
} else {
GPCR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON);
GPCR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN);
}
}
static void corgi_discharge(int on)
{
if (on)
GPSR(CORGI_GPIO_DISCHARGE_ON) = GPIO_bit(CORGI_GPIO_DISCHARGE_ON);
else
GPCR(CORGI_GPIO_DISCHARGE_ON) = GPIO_bit(CORGI_GPIO_DISCHARGE_ON);
}
static void corgi_presuspend(void)
{
int i;
unsigned long wakeup_mask;
/* charging , so CHARGE_ON bit is HIGH during OFF. */
if (READ_GPIO_BIT(CORGI_GPIO_CHRG_ON))
PGSR1 |= GPIO_bit(CORGI_GPIO_CHRG_ON);
else
PGSR1 &= ~GPIO_bit(CORGI_GPIO_CHRG_ON);
if (READ_GPIO_BIT(CORGI_GPIO_LED_ORANGE))
PGSR0 |= GPIO_bit(CORGI_GPIO_LED_ORANGE);
else
PGSR0 &= ~GPIO_bit(CORGI_GPIO_LED_ORANGE);
if (READ_GPIO_BIT(CORGI_GPIO_CHRG_UKN))
PGSR1 |= GPIO_bit(CORGI_GPIO_CHRG_UKN);
else
PGSR1 &= ~GPIO_bit(CORGI_GPIO_CHRG_UKN);
/* Resume on keyboard power key */
PGSR2 = (PGSR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(0);
wakeup_mask = GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) | GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_CHRG_FULL);
if (!machine_is_corgi())
wakeup_mask |= GPIO_bit(CORGI_GPIO_MAIN_BAT_LOW);
PWER = wakeup_mask | PWER_RTC;
PRER = wakeup_mask;
PFER = wakeup_mask;
for (i = 0; i <=15; i++) {
if (PRER & PFER & GPIO_bit(i)) {
if (GPLR0 & GPIO_bit(i) )
PRER &= ~GPIO_bit(i);
else
PFER &= ~GPIO_bit(i);
}
}
}
static void corgi_postsuspend(void)
{
}
/*
* Check what brought us out of the suspend.
* Return: 0 to sleep, otherwise wake
*/
static int corgi_should_wakeup(unsigned int resume_on_alarm)
{
int is_resume = 0;
dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR);
if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) {
if (STATUS_AC_IN()) {
/* charge on */
dev_dbg(sharpsl_pm.dev, "ac insert\n");
sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG;
} else {
/* charge off */
dev_dbg(sharpsl_pm.dev, "ac remove\n");
CHARGE_LED_OFF();
CHARGE_OFF();
sharpsl_pm.charge_mode = CHRG_OFF;
}
}
if ((PEDR & GPIO_bit(CORGI_GPIO_CHRG_FULL)))
dev_dbg(sharpsl_pm.dev, "Charge full interrupt\n");
if (PEDR & GPIO_bit(CORGI_GPIO_KEY_INT))
is_resume |= GPIO_bit(CORGI_GPIO_KEY_INT);
if (PEDR & GPIO_bit(CORGI_GPIO_WAKEUP))
is_resume |= GPIO_bit(CORGI_GPIO_WAKEUP);
if (resume_on_alarm && (PEDR & PWER_RTC))
is_resume |= PWER_RTC;
dev_dbg(sharpsl_pm.dev, "is_resume: %x\n",is_resume);
return is_resume;
}
static unsigned long corgi_charger_wakeup(void)
{
return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) );
}
static int corgi_acin_status(void)
{
return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0);
}
static struct sharpsl_charger_machinfo corgi_pm_machinfo = {
.init = corgi_charger_init,
.gpio_batlock = CORGI_GPIO_BAT_COVER,
.gpio_acin = CORGI_GPIO_AC_IN,
.gpio_batfull = CORGI_GPIO_CHRG_FULL,
.status_acin = corgi_acin_status,
.discharge = corgi_discharge,
.charge = corgi_charge,
.chargeled = corgi_charge_led,
.measure_temp = corgi_measure_temp,
.presuspend = corgi_presuspend,
.postsuspend = corgi_postsuspend,
.charger_wakeup = corgi_charger_wakeup,
.should_wakeup = corgi_should_wakeup,
.bat_levels = 40,
.bat_levels_noac = spitz_battery_levels_noac,
.bat_levels_acin = spitz_battery_levels_acin,
.status_high_acin = 188,
.status_low_acin = 178,
.status_high_noac = 185,
.status_low_noac = 175,
};
static struct platform_device *corgipm_device;
static int __devinit corgipm_init(void)
{
int ret;
corgipm_device = platform_device_alloc("sharpsl-pm", -1);
if (!corgipm_device)
return -ENOMEM;
corgipm_device->dev.platform_data = &corgi_pm_machinfo;
ret = platform_device_add(corgipm_device);
if (ret)
platform_device_put(corgipm_device);
return ret;
}
static void corgipm_exit(void)
{
platform_device_unregister(corgipm_device);
}
module_init(corgipm_init);
module_exit(corgipm_exit);
...@@ -115,7 +115,7 @@ extern struct battery_thresh spitz_battery_levels_noac[]; ...@@ -115,7 +115,7 @@ extern struct battery_thresh spitz_battery_levels_noac[];
#define CHARGE_LED_ERR() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ERROR) #define CHARGE_LED_ERR() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ERROR)
#define DISCHARGE_ON() sharpsl_pm.machinfo->discharge(1) #define DISCHARGE_ON() sharpsl_pm.machinfo->discharge(1)
#define DISCHARGE_OFF() sharpsl_pm.machinfo->discharge(0) #define DISCHARGE_OFF() sharpsl_pm.machinfo->discharge(0)
#define STATUS_AC_IN sharpsl_pm.machinfo->status_acin() #define STATUS_AC_IN() sharpsl_pm.machinfo->status_acin()
#define STATUS_BATT_LOCKED READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock) #define STATUS_BATT_LOCKED() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock)
#define STATUS_CHRG_FULL READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull) #define STATUS_CHRG_FULL() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull)
#define STATUS_FATAL READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal) #define STATUS_FATAL() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal)
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <linux/apm_bios.h> #include <linux/apm_bios.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/device.h> #include <linux/platform_device.h>
#include <asm/hardware.h> #include <asm/hardware.h>
#include <asm/hardware/scoop.h> #include <asm/hardware/scoop.h>
...@@ -45,15 +45,15 @@ ...@@ -45,15 +45,15 @@
#define SHARPSL_WAIT_DISCHARGE_ON 100 /* 100 msec */ #define SHARPSL_WAIT_DISCHARGE_ON 100 /* 100 msec */
#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP 10 /* 10 msec */ #define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP 10 /* 10 msec */
#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT 10 /* 10 msec */ #define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT 10 /* 10 msec */
#define SHARPSL_CHECK_BATTERY_WAIT_TIME_JKVAD 10 /* 10 msec */ #define SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN 10 /* 10 msec */
#define SHARPSL_CHARGE_WAIT_TIME 15 /* 15 msec */ #define SHARPSL_CHARGE_WAIT_TIME 15 /* 15 msec */
#define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */ #define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */
#define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */ #define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */
#define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */ #define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */
#define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */ #define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */
#define SHARPSL_CHARGE_ON_JKVAD_HIGH 0x9b /* 6V */ #define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */
#define SHARPSL_CHARGE_ON_JKVAD_LOW 0x34 /* 2V */ #define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */
#define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */ #define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */
#define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */ #define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */
...@@ -160,9 +160,10 @@ struct battery_thresh spitz_battery_levels_noac[] = { ...@@ -160,9 +160,10 @@ struct battery_thresh spitz_battery_levels_noac[] = {
/* /*
* Prototypes * Prototypes
*/ */
static int sharpsl_read_MainBattery(void); static int sharpsl_read_main_battery(void);
static int sharpsl_off_charge_battery(void); static int sharpsl_off_charge_battery(void);
static int sharpsl_check_battery(int mode); static int sharpsl_check_battery_temp(void);
static int sharpsl_check_battery_voltage(void);
static int sharpsl_ac_check(void); static int sharpsl_ac_check(void);
static int sharpsl_fatal_check(void); static int sharpsl_fatal_check(void);
static int sharpsl_average_value(int ad); static int sharpsl_average_value(int ad);
...@@ -228,7 +229,7 @@ static void sharpsl_battery_thread(void *private_) ...@@ -228,7 +229,7 @@ static void sharpsl_battery_thread(void *private_)
if (!sharpsl_pm.machinfo) if (!sharpsl_pm.machinfo)
return; return;
sharpsl_pm.battstat.ac_status = (!(STATUS_AC_IN) ? APM_AC_OFFLINE : APM_AC_ONLINE); sharpsl_pm.battstat.ac_status = (STATUS_AC_IN() ? APM_AC_ONLINE : APM_AC_OFFLINE);
/* Corgi cannot confirm when battery fully charged so periodically kick! */ /* Corgi cannot confirm when battery fully charged so periodically kick! */
if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON) if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON)
...@@ -236,7 +237,7 @@ static void sharpsl_battery_thread(void *private_) ...@@ -236,7 +237,7 @@ static void sharpsl_battery_thread(void *private_)
schedule_work(&toggle_charger); schedule_work(&toggle_charger);
while(1) { while(1) {
voltage = sharpsl_read_MainBattery(); voltage = sharpsl_read_main_battery();
if (voltage > 0) break; if (voltage > 0) break;
if (i++ > 5) { if (i++ > 5) {
voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage; voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage;
...@@ -317,10 +318,10 @@ static void sharpsl_charge_toggle(void *private_) ...@@ -317,10 +318,10 @@ static void sharpsl_charge_toggle(void *private_)
{ {
dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies); dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies);
if (STATUS_AC_IN == 0) { if (STATUS_AC_IN() == 0) {
sharpsl_charge_off(); sharpsl_charge_off();
return; return;
} else if ((sharpsl_check_battery(1) < 0) || (sharpsl_ac_check() < 0)) { } else if ((sharpsl_check_battery_temp() < 0) || (sharpsl_ac_check() < 0)) {
sharpsl_charge_error(); sharpsl_charge_error();
return; return;
} }
...@@ -335,7 +336,7 @@ static void sharpsl_charge_toggle(void *private_) ...@@ -335,7 +336,7 @@ static void sharpsl_charge_toggle(void *private_)
static void sharpsl_ac_timer(unsigned long data) static void sharpsl_ac_timer(unsigned long data)
{ {
int acin = STATUS_AC_IN; int acin = STATUS_AC_IN();
dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin); dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin);
...@@ -364,7 +365,7 @@ static void sharpsl_chrg_full_timer(unsigned long data) ...@@ -364,7 +365,7 @@ static void sharpsl_chrg_full_timer(unsigned long data)
sharpsl_pm.full_count++; sharpsl_pm.full_count++;
if (STATUS_AC_IN == 0) { if (STATUS_AC_IN() == 0) {
dev_dbg(sharpsl_pm.dev, "Charge Full: AC removed - stop charging!\n"); dev_dbg(sharpsl_pm.dev, "Charge Full: AC removed - stop charging!\n");
if (sharpsl_pm.charge_mode == CHRG_ON) if (sharpsl_pm.charge_mode == CHRG_ON)
sharpsl_charge_off(); sharpsl_charge_off();
...@@ -399,12 +400,12 @@ static irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp) ...@@ -399,12 +400,12 @@ static irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp)
{ {
int is_fatal = 0; int is_fatal = 0;
if (STATUS_BATT_LOCKED == 0) { if (STATUS_BATT_LOCKED() == 0) {
dev_err(sharpsl_pm.dev, "Battery now Unlocked! Suspending.\n"); dev_err(sharpsl_pm.dev, "Battery now Unlocked! Suspending.\n");
is_fatal = 1; is_fatal = 1;
} }
if (sharpsl_pm.machinfo->gpio_fatal && (STATUS_FATAL == 0)) { if (sharpsl_pm.machinfo->gpio_fatal && (STATUS_FATAL() == 0)) {
dev_err(sharpsl_pm.dev, "Fatal Batt Error! Suspending.\n"); dev_err(sharpsl_pm.dev, "Fatal Batt Error! Suspending.\n");
is_fatal = 1; is_fatal = 1;
} }
...@@ -461,12 +462,12 @@ static int read_max1111(int channel) ...@@ -461,12 +462,12 @@ static int read_max1111(int channel)
| MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR); | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR);
} }
static int sharpsl_read_MainBattery(void) static int sharpsl_read_main_battery(void)
{ {
return read_max1111(BATT_AD); return read_max1111(BATT_AD);
} }
static int sharpsl_read_Temp(void) static int sharpsl_read_temp(void)
{ {
int temp; int temp;
...@@ -480,7 +481,7 @@ static int sharpsl_read_Temp(void) ...@@ -480,7 +481,7 @@ static int sharpsl_read_Temp(void)
return temp; return temp;
} }
static int sharpsl_read_jkvad(void) static int sharpsl_read_acin(void)
{ {
return read_max1111(JK_VAD); return read_max1111(JK_VAD);
} }
...@@ -522,16 +523,14 @@ static int get_select_val(int *val) ...@@ -522,16 +523,14 @@ static int get_select_val(int *val)
return (sum/3); return (sum/3);
} }
/* mode 0 - Check temperature and voltage static int sharpsl_check_battery_temp(void)
* 1 - Check temperature only */
static int sharpsl_check_battery(int mode)
{ {
int val, i, buff[5]; int val, i, buff[5];
/* Check battery temperature */ /* Check battery temperature */
for (i=0; i<5; i++) { for (i=0; i<5; i++) {
mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP); mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
buff[i] = sharpsl_read_Temp(); buff[i] = sharpsl_read_temp();
} }
val = get_select_val(buff); val = get_select_val(buff);
...@@ -539,8 +538,13 @@ static int sharpsl_check_battery(int mode) ...@@ -539,8 +538,13 @@ static int sharpsl_check_battery(int mode)
dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val); dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val);
if (val > SHARPSL_CHARGE_ON_TEMP) if (val > SHARPSL_CHARGE_ON_TEMP)
return -1; return -1;
if (mode == 1)
return 0; return 0;
}
static int sharpsl_check_battery_voltage(void)
{
int val, i, buff[5];
/* disable charge, enable discharge */ /* disable charge, enable discharge */
CHARGE_OFF(); CHARGE_OFF();
...@@ -552,7 +556,7 @@ static int sharpsl_check_battery(int mode) ...@@ -552,7 +556,7 @@ static int sharpsl_check_battery(int mode)
/* Check battery voltage */ /* Check battery voltage */
for (i=0; i<5; i++) { for (i=0; i<5; i++) {
buff[i] = sharpsl_read_MainBattery(); buff[i] = sharpsl_read_main_battery();
mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT); mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
} }
...@@ -575,14 +579,14 @@ static int sharpsl_ac_check(void) ...@@ -575,14 +579,14 @@ static int sharpsl_ac_check(void)
int temp, i, buff[5]; int temp, i, buff[5];
for (i=0; i<5; i++) { for (i=0; i<5; i++) {
buff[i] = sharpsl_read_jkvad(); buff[i] = sharpsl_read_acin();
mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_JKVAD); mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN);
} }
temp = get_select_val(buff); temp = get_select_val(buff);
dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp); dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp);
if ((temp > SHARPSL_CHARGE_ON_JKVAD_HIGH) || (temp < SHARPSL_CHARGE_ON_JKVAD_LOW)) { if ((temp > SHARPSL_CHARGE_ON_ACIN_HIGH) || (temp < SHARPSL_CHARGE_ON_ACIN_LOW)) {
dev_err(sharpsl_pm.dev, "Error: AC check failed.\n"); dev_err(sharpsl_pm.dev, "Error: AC check failed.\n");
return -1; return -1;
} }
...@@ -591,7 +595,7 @@ static int sharpsl_ac_check(void) ...@@ -591,7 +595,7 @@ static int sharpsl_ac_check(void)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int sharpsl_pm_suspend(struct device *dev, pm_message_t state) static int sharpsl_pm_suspend(struct platform_device *pdev, pm_message_t state)
{ {
sharpsl_pm.flags |= SHARPSL_SUSPENDED; sharpsl_pm.flags |= SHARPSL_SUSPENDED;
flush_scheduled_work(); flush_scheduled_work();
...@@ -604,7 +608,7 @@ static int sharpsl_pm_suspend(struct device *dev, pm_message_t state) ...@@ -604,7 +608,7 @@ static int sharpsl_pm_suspend(struct device *dev, pm_message_t state)
return 0; return 0;
} }
static int sharpsl_pm_resume(struct device *dev) static int sharpsl_pm_resume(struct platform_device *pdev)
{ {
/* Clear the reset source indicators as they break the bootloader upon reboot */ /* Clear the reset source indicators as they break the bootloader upon reboot */
RCSR = 0x0f; RCSR = 0x0f;
...@@ -622,7 +626,7 @@ static void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable ...@@ -622,7 +626,7 @@ static void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable
dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG); dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG);
/* not charging and AC-IN! */ /* not charging and AC-IN! */
if ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (STATUS_AC_IN != 0)) { if ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (STATUS_AC_IN() != 0)) {
dev_dbg(sharpsl_pm.dev, "Activating Offline Charger...\n"); dev_dbg(sharpsl_pm.dev, "Activating Offline Charger...\n");
sharpsl_pm.charge_mode = CHRG_OFF; sharpsl_pm.charge_mode = CHRG_OFF;
sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG; sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG;
...@@ -671,7 +675,7 @@ static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enab ...@@ -671,7 +675,7 @@ static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enab
dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n"); dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n");
} }
if ((STATUS_BATT_LOCKED == 0) || (sharpsl_fatal_check() < 0) ) if ((STATUS_BATT_LOCKED() == 0) || (sharpsl_fatal_check() < 0) )
{ {
dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n"); dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n");
corgi_goto_sleep(alarm_time, alarm_enable, state); corgi_goto_sleep(alarm_time, alarm_enable, state);
...@@ -711,7 +715,7 @@ static int sharpsl_fatal_check(void) ...@@ -711,7 +715,7 @@ static int sharpsl_fatal_check(void)
dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check entered\n"); dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check entered\n");
/* Check AC-Adapter */ /* Check AC-Adapter */
acin = STATUS_AC_IN; acin = STATUS_AC_IN();
if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) { if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) {
CHARGE_OFF(); CHARGE_OFF();
...@@ -725,7 +729,7 @@ static int sharpsl_fatal_check(void) ...@@ -725,7 +729,7 @@ static int sharpsl_fatal_check(void)
/* Check battery : check inserting battery ? */ /* Check battery : check inserting battery ? */
for (i=0; i<5; i++) { for (i=0; i<5; i++) {
buff[i] = sharpsl_read_MainBattery(); buff[i] = sharpsl_read_main_battery();
mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT); mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
} }
...@@ -739,7 +743,7 @@ static int sharpsl_fatal_check(void) ...@@ -739,7 +743,7 @@ static int sharpsl_fatal_check(void)
} }
temp = get_select_val(buff); temp = get_select_val(buff);
dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_read_MainBattery()); dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_read_main_battery());
if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) || if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) ||
(!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT))) (!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT)))
...@@ -771,7 +775,7 @@ static int sharpsl_off_charge_battery(void) ...@@ -771,7 +775,7 @@ static int sharpsl_off_charge_battery(void)
dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 1\n"); dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 1\n");
/* AC Check */ /* AC Check */
if ((sharpsl_ac_check() < 0) || (sharpsl_check_battery(1) < 0)) if ((sharpsl_ac_check() < 0) || (sharpsl_check_battery_temp() < 0))
return sharpsl_off_charge_error(); return sharpsl_off_charge_error();
/* Start Charging */ /* Start Charging */
...@@ -793,7 +797,7 @@ static int sharpsl_off_charge_battery(void) ...@@ -793,7 +797,7 @@ static int sharpsl_off_charge_battery(void)
dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 2\n"); dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 2\n");
if (sharpsl_check_battery(0) < 0) if ((sharpsl_check_battery_temp() < 0) || (sharpsl_check_battery_voltage() < 0))
return sharpsl_off_charge_error(); return sharpsl_off_charge_error();
CHARGE_OFF(); CHARGE_OFF();
...@@ -811,7 +815,7 @@ static int sharpsl_off_charge_battery(void) ...@@ -811,7 +815,7 @@ static int sharpsl_off_charge_battery(void)
/* Check for timeout */ /* Check for timeout */
if ((RCNR - time) > SHARPSL_WAIT_CO_TIME) if ((RCNR - time) > SHARPSL_WAIT_CO_TIME)
return 1; return 1;
if (STATUS_CHRG_FULL) { if (STATUS_CHRG_FULL()) {
dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n"); dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n");
sharpsl_pm.full_count++; sharpsl_pm.full_count++;
CHARGE_OFF(); CHARGE_OFF();
...@@ -840,7 +844,7 @@ static int sharpsl_off_charge_battery(void) ...@@ -840,7 +844,7 @@ static int sharpsl_off_charge_battery(void)
sharpsl_pm.full_count++; sharpsl_pm.full_count++;
return 1; return 1;
} }
if (STATUS_CHRG_FULL) { if (STATUS_CHRG_FULL()) {
dev_dbg(sharpsl_pm.dev, "Offline Charger: Charging complete.\n"); dev_dbg(sharpsl_pm.dev, "Offline Charger: Charging complete.\n");
CHARGE_LED_OFF(); CHARGE_LED_OFF();
CHARGE_OFF(); CHARGE_OFF();
...@@ -886,13 +890,13 @@ static struct pm_ops sharpsl_pm_ops = { ...@@ -886,13 +890,13 @@ static struct pm_ops sharpsl_pm_ops = {
.finish = pxa_pm_finish, .finish = pxa_pm_finish,
}; };
static int __init sharpsl_pm_probe(struct device *dev) static int __init sharpsl_pm_probe(struct platform_device *pdev)
{ {
if (!dev->platform_data) if (!pdev->dev.platform_data)
return -EINVAL; return -EINVAL;
sharpsl_pm.dev = dev; sharpsl_pm.dev = &pdev->dev;
sharpsl_pm.machinfo = dev->platform_data; sharpsl_pm.machinfo = pdev->dev.platform_data;
sharpsl_pm.charge_mode = CHRG_OFF; sharpsl_pm.charge_mode = CHRG_OFF;
sharpsl_pm.flags = 0; sharpsl_pm.flags = 0;
...@@ -935,8 +939,8 @@ static int __init sharpsl_pm_probe(struct device *dev) ...@@ -935,8 +939,8 @@ static int __init sharpsl_pm_probe(struct device *dev)
else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING); else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING);
} }
device_create_file(dev, &dev_attr_battery_percentage); device_create_file(&pdev->dev, &dev_attr_battery_percentage);
device_create_file(dev, &dev_attr_battery_voltage); device_create_file(&pdev->dev, &dev_attr_battery_voltage);
apm_get_power_status = sharpsl_apm_get_power_status; apm_get_power_status = sharpsl_apm_get_power_status;
...@@ -947,12 +951,12 @@ static int __init sharpsl_pm_probe(struct device *dev) ...@@ -947,12 +951,12 @@ static int __init sharpsl_pm_probe(struct device *dev)
return 0; return 0;
} }
static int sharpsl_pm_remove(struct device *dev) static int sharpsl_pm_remove(struct platform_device *pdev)
{ {
pm_set_ops(NULL); pm_set_ops(NULL);
device_remove_file(dev, &dev_attr_battery_percentage); device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
device_remove_file(dev, &dev_attr_battery_voltage); device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr); free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr);
free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr); free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr);
...@@ -969,23 +973,24 @@ static int sharpsl_pm_remove(struct device *dev) ...@@ -969,23 +973,24 @@ static int sharpsl_pm_remove(struct device *dev)
return 0; return 0;
} }
static struct device_driver sharpsl_pm_driver = { static struct platform_driver sharpsl_pm_driver = {
.name = "sharpsl-pm",
.bus = &platform_bus_type,
.probe = sharpsl_pm_probe, .probe = sharpsl_pm_probe,
.remove = sharpsl_pm_remove, .remove = sharpsl_pm_remove,
.suspend = sharpsl_pm_suspend, .suspend = sharpsl_pm_suspend,
.resume = sharpsl_pm_resume, .resume = sharpsl_pm_resume,
.driver = {
.name = "sharpsl-pm",
},
}; };
static int __devinit sharpsl_pm_init(void) static int __devinit sharpsl_pm_init(void)
{ {
return driver_register(&sharpsl_pm_driver); return platform_driver_register(&sharpsl_pm_driver);
} }
static void sharpsl_pm_exit(void) static void sharpsl_pm_exit(void)
{ {
driver_unregister(&sharpsl_pm_driver); platform_driver_unregister(&sharpsl_pm_driver);
} }
late_initcall(sharpsl_pm_init); late_initcall(sharpsl_pm_init);
......
...@@ -345,6 +345,16 @@ static void spitz_irda_transceiver_mode(struct device *dev, int mode) ...@@ -345,6 +345,16 @@ static void spitz_irda_transceiver_mode(struct device *dev, int mode)
reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON); reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
} }
#ifdef CONFIG_MACH_AKITA
static void akita_irda_transceiver_mode(struct device *dev, int mode)
{
if (mode & IR_OFF)
akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
else
akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
}
#endif
static struct pxaficp_platform_data spitz_ficp_platform_data = { static struct pxaficp_platform_data spitz_ficp_platform_data = {
.transceiver_cap = IR_SIRMODE | IR_OFF, .transceiver_cap = IR_SIRMODE | IR_OFF,
.transceiver_mode = spitz_irda_transceiver_mode, .transceiver_mode = spitz_irda_transceiver_mode,
...@@ -417,6 +427,32 @@ static void __init spitz_init(void) ...@@ -417,6 +427,32 @@ static void __init spitz_init(void)
platform_device_register(&spitzscoop2_device); platform_device_register(&spitzscoop2_device);
} }
#ifdef CONFIG_MACH_AKITA
/*
* Akita IO Expander
*/
struct platform_device akitaioexp_device = {
.name = "akita-ioexp",
.id = -1,
};
static void __init akita_init(void)
{
spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
/* We just pretend the second element of the array doesn't exist */
spitz_pcmcia_config.num_devs = 1;
platform_scoop_config = &spitz_pcmcia_config;
spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity;
platform_device_register(&akitaioexp_device);
spitzscoop_device.dev.parent = &akitaioexp_device.dev;
common_init();
}
#endif
static void __init fixup_spitz(struct machine_desc *desc, static void __init fixup_spitz(struct machine_desc *desc,
struct tag *tags, char **cmdline, struct meminfo *mi) struct tag *tags, char **cmdline, struct meminfo *mi)
{ {
...@@ -452,3 +488,16 @@ MACHINE_START(BORZOI, "SHARP Borzoi") ...@@ -452,3 +488,16 @@ MACHINE_START(BORZOI, "SHARP Borzoi")
.timer = &pxa_timer, .timer = &pxa_timer,
MACHINE_END MACHINE_END
#endif #endif
#ifdef CONFIG_MACH_AKITA
MACHINE_START(AKITA, "SHARP Akita")
.phys_ram = 0xa0000000,
.phys_io = 0x40000000,
.io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
.fixup = fixup_spitz,
.map_io = pxa_map_io,
.init_irq = pxa_init_irq,
.init_machine = akita_init,
.timer = &pxa_timer,
MACHINE_END
#endif
/*
* Battery and Power Management code for the Sharp SL-Cxx00
*
* Copyright (c) 2005 Richard Purdie
*
* 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.
*
*/
#include <linux/module.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <asm/apm.h>
#include <asm/irq.h>
#include <asm/mach-types.h>
#include <asm/hardware.h>
#include <asm/hardware/scoop.h>
#include <asm/arch/sharpsl.h>
#include <asm/arch/spitz.h>
#include <asm/arch/pxa-regs.h>
#include "sharpsl.h"
static int spitz_last_ac_status;
static void spitz_charger_init(void)
{
pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN);
pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
}
static void spitz_charge_led(int val)
{
if (val == SHARPSL_LED_ERROR) {
dev_dbg(sharpsl_pm.dev, "Charge LED Error\n");
} else if (val == SHARPSL_LED_ON) {
dev_dbg(sharpsl_pm.dev, "Charge LED On\n");
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
} else {
dev_dbg(sharpsl_pm.dev, "Charge LED Off\n");
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
}
}
static void spitz_measure_temp(int on)
{
if (on)
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
else
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
}
static void spitz_charge(int on)
{
if (on) {
if (sharpsl_pm.flags & SHARPSL_SUSPENDED) {
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B);
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON);
} else {
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B);
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON);
}
} else {
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B);
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON);
}
}
static void spitz_discharge(int on)
{
if (on)
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
else
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
}
/* HACK - For unknown reasons, accurate voltage readings are only made with a load
on the power bus which the green led on spitz provides */
static void spitz_discharge1(int on)
{
if (on)
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
else
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
}
static void spitz_presuspend(void)
{
spitz_last_ac_status = STATUS_AC_IN();
/* GPIO Sleep Register */
PGSR0 = 0x00144018;
PGSR1 = 0x00EF0000;
if (machine_is_akita()) {
PGSR2 = 0x2121C000;
PGSR3 = 0x00600400;
} else {
PGSR2 = 0x0121C000;
PGSR3 = 0x00600000;
}
PGSR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
PGSR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
PGSR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
PGSR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
PGSR2 |= GPIO_bit(SPITZ_GPIO_KEY_STROBE0);
pxa_gpio_mode(GPIO18_RDY|GPIO_OUT | GPIO_DFLT_HIGH);
PRER = GPIO_bit(SPITZ_GPIO_KEY_INT);
PFER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET);
PWER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET) | PWER_RTC;
PKWR = GPIO_bit(SPITZ_GPIO_SYNC) | GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET);
PKSR = 0xffffffff; // clear
/* nRESET_OUT Disable */
PSLR |= PSLR_SL_ROD;
/* Clear reset status */
RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
/* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
PCFR = PCFR_GPR_EN | PCFR_OPDE;
}
static void spitz_postsuspend(void)
{
pxa_gpio_mode(GPIO18_RDY_MD);
pxa_gpio_mode(10 | GPIO_IN);
}
static int spitz_should_wakeup(unsigned int resume_on_alarm)
{
int is_resume = 0;
int acin = STATUS_AC_IN();
if (spitz_last_ac_status != acin) {
if (acin) {
/* charge on */
sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG;
dev_dbg(sharpsl_pm.dev, "AC Inserted\n");
} else {
/* charge off */
dev_dbg(sharpsl_pm.dev, "AC Removed\n");
CHARGE_LED_OFF();
CHARGE_OFF();
sharpsl_pm.charge_mode = CHRG_OFF;
}
spitz_last_ac_status = acin;
/* Return to suspend as this must be what we were woken for */
return 0;
}
if (PEDR & GPIO_bit(SPITZ_GPIO_KEY_INT))
is_resume |= GPIO_bit(SPITZ_GPIO_KEY_INT);
if (PKSR & GPIO_bit(SPITZ_GPIO_SYNC))
is_resume |= GPIO_bit(SPITZ_GPIO_SYNC);
if (resume_on_alarm && (PEDR & PWER_RTC))
is_resume |= PWER_RTC;
dev_dbg(sharpsl_pm.dev, "is_resume: %x\n",is_resume);
return is_resume;
}
static unsigned long spitz_charger_wakeup(void)
{
return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC));
}
static int spitz_acin_status(void)
{
return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0);
}
struct sharpsl_charger_machinfo spitz_pm_machinfo = {
.init = spitz_charger_init,
.gpio_batlock = SPITZ_GPIO_BAT_COVER,
.gpio_acin = SPITZ_GPIO_AC_IN,
.gpio_batfull = SPITZ_GPIO_CHRG_FULL,
.gpio_fatal = SPITZ_GPIO_FATAL_BAT,
.status_acin = spitz_acin_status,
.discharge = spitz_discharge,
.discharge1 = spitz_discharge1,
.charge = spitz_charge,
.chargeled = spitz_charge_led,
.measure_temp = spitz_measure_temp,
.presuspend = spitz_presuspend,
.postsuspend = spitz_postsuspend,
.charger_wakeup = spitz_charger_wakeup,
.should_wakeup = spitz_should_wakeup,
.bat_levels = 40,
.bat_levels_noac = spitz_battery_levels_noac,
.bat_levels_acin = spitz_battery_levels_acin,
.status_high_acin = 188,
.status_low_acin = 178,
.status_high_noac = 185,
.status_low_noac = 175,
};
static struct platform_device *spitzpm_device;
static int __devinit spitzpm_init(void)
{
int ret;
spitzpm_device = platform_device_alloc("sharpsl-pm", -1);
if (!spitzpm_device)
return -ENOMEM;
spitzpm_device->dev.platform_data = &spitz_pm_machinfo;
ret = platform_device_add(spitzpm_device);
if (ret)
platform_device_put(spitzpm_device);
return ret;
}
static void spitzpm_exit(void)
{
platform_device_unregister(spitzpm_device);
}
module_init(spitzpm_init);
module_exit(spitzpm_exit);
...@@ -399,34 +399,6 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c ...@@ -399,34 +399,6 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c
return dev->irq; return dev->irq;
} }
static void __devinit init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base)
{
unsigned int rev;
u8 dma_state;
DBG(("init_dma_sl82c105(hwif: ide%d, dma_base: 0x%08x)\n", hwif->index, dma_base));
hwif->autodma = 0;
if (!dma_base)
return;
dma_state = hwif->INB(dma_base + 2);
rev = sl82c105_bridge_revision(hwif->pci_dev);
if (rev <= 5) {
printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
hwif->name, rev);
dma_state &= ~0x60;
} else {
dma_state |= 0x60;
if (!noautodma)
hwif->autodma = 1;
}
hwif->OUTB(dma_state, dma_base + 2);
ide_setup_dma(hwif, dma_base, 8);
}
/* /*
* Initialise the chip * Initialise the chip
*/ */
...@@ -434,6 +406,8 @@ static void __devinit init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base ...@@ -434,6 +406,8 @@ static void __devinit init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base
static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
{ {
struct pci_dev *dev = hwif->pci_dev; struct pci_dev *dev = hwif->pci_dev;
unsigned int rev;
u8 dma_state;
u32 val; u32 val;
DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index));
...@@ -455,14 +429,31 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) ...@@ -455,14 +429,31 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
pci_read_config_dword(dev, 0x40, &val); pci_read_config_dword(dev, 0x40, &val);
*((u32 *)&hwif->hwif_data) = val; *((u32 *)&hwif->hwif_data) = val;
hwif->atapi_dma = 0;
hwif->mwdma_mask = 0;
hwif->swdma_mask = 0;
hwif->autodma = 0;
if (!hwif->dma_base) if (!hwif->dma_base)
return; return;
dma_state = hwif->INB(hwif->dma_base + 2) & ~0x60;
rev = sl82c105_bridge_revision(hwif->pci_dev);
if (rev <= 5) {
/*
* Never ever EVER under any circumstances enable
* DMA when the bridge is this old.
*/
printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
hwif->name, rev);
} else {
#ifdef CONFIG_BLK_DEV_IDEDMA
dma_state |= 0x60;
hwif->atapi_dma = 1; hwif->atapi_dma = 1;
hwif->mwdma_mask = 0x07; hwif->mwdma_mask = 0x07;
hwif->swdma_mask = 0x07; hwif->swdma_mask = 0x07;
#ifdef CONFIG_BLK_DEV_IDEDMA
hwif->ide_dma_check = &sl82c105_check_drive; hwif->ide_dma_check = &sl82c105_check_drive;
hwif->ide_dma_on = &sl82c105_ide_dma_on; hwif->ide_dma_on = &sl82c105_ide_dma_on;
hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly; hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly;
...@@ -474,14 +465,18 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) ...@@ -474,14 +465,18 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
hwif->autodma = 1; hwif->autodma = 1;
hwif->drives[0].autodma = hwif->autodma; hwif->drives[0].autodma = hwif->autodma;
hwif->drives[1].autodma = hwif->autodma; hwif->drives[1].autodma = hwif->autodma;
if (hwif->mate)
hwif->serialized = hwif->mate->serialized = 1;
#endif /* CONFIG_BLK_DEV_IDEDMA */ #endif /* CONFIG_BLK_DEV_IDEDMA */
}
hwif->OUTB(dma_state, hwif->dma_base + 2);
} }
static ide_pci_device_t sl82c105_chipset __devinitdata = { static ide_pci_device_t sl82c105_chipset __devinitdata = {
.name = "W82C105", .name = "W82C105",
.init_chipset = init_chipset_sl82c105, .init_chipset = init_chipset_sl82c105,
.init_hwif = init_hwif_sl82c105, .init_hwif = init_hwif_sl82c105,
.init_dma = init_dma_sl82c105,
.channels = 2, .channels = 2,
.autodma = NOAUTODMA, .autodma = NOAUTODMA,
.enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
......
...@@ -100,14 +100,14 @@ ...@@ -100,14 +100,14 @@
#define SMC_IO_SHIFT 0 #define SMC_IO_SHIFT 0
#define SMC_NOWAIT 1 #define SMC_NOWAIT 1
#define SMC_inb(a, r) inb((a) + (r)) #define SMC_inb(a, r) readb((a) + (r))
#define SMC_insb(a, r, p, l) insb((a) + (r), p, (l)) #define SMC_insb(a, r, p, l) readsb((a) + (r), p, (l))
#define SMC_inw(a, r) inw((a) + (r)) #define SMC_inw(a, r) readw((a) + (r))
#define SMC_insw(a, r, p, l) insw((a) + (r), p, l) #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
#define SMC_outb(v, a, r) outb(v, (a) + (r)) #define SMC_outb(v, a, r) writeb(v, (a) + (r))
#define SMC_outsb(a, r, p, l) outsb((a) + (r), p, (l)) #define SMC_outsb(a, r, p, l) writesb((a) + (r), p, (l))
#define SMC_outw(v, a, r) outw(v, (a) + (r)) #define SMC_outw(v, a, r) writew(v, (a) + (r))
#define SMC_outsw(a, r, p, l) outsw((a) + (r), p, l) #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
#define set_irq_type(irq, type) do {} while (0) #define set_irq_type(irq, type) do {} while (0)
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
/* Default Values */ /* Default Values */
#define AKITA_IOEXP_IO_OUT (AKITA_IOEXP_IR_ON | AKITA_IOEXP_AKIN_PULLUP) #define AKITA_IOEXP_IO_OUT (AKITA_IOEXP_IR_ON | AKITA_IOEXP_AKIN_PULLUP)
extern struct platform_device akitaioexp_device;
void akita_set_ioexp(struct device *dev, unsigned char bitmask); void akita_set_ioexp(struct device *dev, unsigned char bitmask);
void akita_reset_ioexp(struct device *dev, unsigned char bitmask); void akita_reset_ioexp(struct device *dev, unsigned char bitmask);
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
#define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */ #define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */
#define I2C_DRIVERID_SAA7127 72 /* saa7124 video encoder */ #define I2C_DRIVERID_SAA7127 72 /* saa7124 video encoder */
#define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */ #define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */
#define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */
#define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */ #define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */
#define I2C_DRIVERID_EXP1 0xF1 #define I2C_DRIVERID_EXP1 0xF1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment