X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Farm%2Fmach-sa1100%2Fcollie_pm.c;h=696d7d29c8a5bf7496bc35f9703cb25d0bd17501;hb=9464c7cf61b9433057924c36e6e02f303a00e768;hp=1e25b1d19fce7e7f537269a5df27a27584be8b3d;hpb=41689045f6a3cbe0550e1d34e9cc20d2e8c432ba;p=linux-2.6.git diff --git a/arch/arm/mach-sa1100/collie_pm.c b/arch/arm/mach-sa1100/collie_pm.c index 1e25b1d19..696d7d29c 100644 --- a/arch/arm/mach-sa1100/collie_pm.c +++ b/arch/arm/mach-sa1100/collie_pm.c @@ -9,9 +9,6 @@ * Li-ion batteries are angry beasts, and they like to explode. This driver is not finished, * and sometimes charges them when it should not. If it makes angry lithium to come your way... * ...well, you have been warned. - * - * Actually, this should be quite safe, it seems sharp leaves charger enabled by default, - * and my collie did not explode (yet). */ #include @@ -43,16 +40,17 @@ static void collie_charger_init(void) { int err; - if (sharpsl_param.adadj != -1) + if (sharpsl_param.adadj != -1) { ad_revise = sharpsl_param.adadj; + } /* Register interrupt handler. */ - if ((err = request_irq(COLLIE_IRQ_GPIO_AC_IN, sharpsl_ac_isr, IRQF_DISABLED, + if ((err = request_irq(COLLIE_IRQ_GPIO_AC_IN, sharpsl_ac_isr, SA_INTERRUPT, "ACIN", sharpsl_ac_isr))) { printk("Could not get irq %d.\n", COLLIE_IRQ_GPIO_AC_IN); return; } - if ((err = request_irq(COLLIE_IRQ_GPIO_CO, sharpsl_chrg_full_isr, IRQF_DISABLED, + if ((err = request_irq(COLLIE_IRQ_GPIO_CO, sharpsl_chrg_full_isr, SA_INTERRUPT, "CO", sharpsl_chrg_full_isr))) { free_irq(COLLIE_IRQ_GPIO_AC_IN, sharpsl_ac_isr); printk("Could not get irq %d.\n", COLLIE_IRQ_GPIO_CO); @@ -74,17 +72,27 @@ static void collie_measure_temp(int on) static void collie_charge(int on) { - extern struct platform_device colliescoop_device; + if (on) { + printk("Should start charger\n"); + } else { + printk("Should stop charger\n"); + } +#ifdef I_AM_SURE - /* Zaurus seems to contain LTC1731; it should know when to + /* Zaurus seems to contain LTC1731 ; it should know when to * stop charging itself, so setting charge on should be * relatively harmless (as long as it is not done too often). */ +#define CF_BUF_CTRL_BASE 0xF0800000 +#define SCOOP_REG(adr) (*(volatile unsigned short*)(CF_BUF_CTRL_BASE+(adr))) +#define SCOOP_REG_GPWR SCOOP_REG(SCOOP_GPWR) + if (on) { set_scoop_gpio(&colliescoop_device.dev, COLLIE_SCP_CHARGE_ON); } else { reset_scoop_gpio(&colliescoop_device.dev, COLLIE_SCP_CHARGE_ON); } +#endif } static void collie_discharge(int on) @@ -119,6 +127,7 @@ int collie_read_backup_battery(void) ucb1x00_adc_enable(ucb); + /* Gives 75..130 */ ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_BBAT_ON, 0); voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC); @@ -137,8 +146,9 @@ int collie_read_main_battery(void) ucb1x00_adc_enable(ucb); ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_BBAT_ON); ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_MBAT_ON, 0); - - mdelay(1); + /* gives values 160..255 with battery removed... and + 145..255 with battery inserted. (on AC), goes as low as + 80 on DC. */ voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC); ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_MBAT_ON); @@ -182,7 +192,7 @@ static unsigned long read_devdata(int which) case SHARPSL_BATT_TEMP: return collie_read_temp(); case SHARPSL_ACIN_VOLT: - return 500; + return 0x1; case SHARPSL_STATUS_ACIN: { int ret = GPLR & COLLIE_GPIO_AC_IN; printk("AC status = %d\n", ret); @@ -198,33 +208,10 @@ static unsigned long read_devdata(int which) } } -struct battery_thresh collie_battery_levels_acin[] = { - { 420, 100}, - { 417, 95}, - { 415, 90}, - { 413, 80}, - { 411, 75}, - { 408, 70}, - { 406, 60}, - { 403, 50}, - { 398, 40}, - { 391, 25}, - { 10, 5}, - { 0, 0}, -}; - struct battery_thresh collie_battery_levels[] = { - { 394, 100}, - { 390, 95}, - { 380, 90}, - { 370, 80}, - { 368, 75}, /* From sharp code: battery high with frontlight */ - { 366, 70}, /* 60..90 -- fake values invented by me for testing */ - { 364, 60}, - { 362, 50}, - { 360, 40}, - { 358, 25}, /* From sharp code: battery low with frontlight */ - { 356, 5}, /* From sharp code: battery verylow with frontlight */ + { 368, 100}, + { 358, 25}, + { 356, 5}, { 0, 0}, }; @@ -239,21 +226,13 @@ struct sharpsl_charger_machinfo collie_pm_machinfo = { .postsuspend = collie_postsuspend, .charger_wakeup = collie_charger_wakeup, .should_wakeup = collie_should_wakeup, - .bat_levels = 12, + .bat_levels = 3, .bat_levels_noac = collie_battery_levels, - .bat_levels_acin = collie_battery_levels_acin, + .bat_levels_acin = collie_battery_levels, .status_high_acin = 368, .status_low_acin = 358, .status_high_noac = 368, .status_low_noac = 358, - .charge_on_volt = 350, /* spitz uses 2.90V, but lets play it safe. */ - .charge_on_temp = 550, - .charge_acin_high = 550, /* collie does not seem to have sensor for this, anyway */ - .charge_acin_low = 450, /* ignored, too */ - .fatal_acin_volt = 356, - .fatal_noacin_volt = 356, - - .batfull_irq = 1, /* We do not want periodical charge restarts */ }; static int __init collie_pm_ucb_add(struct ucb1x00_dev *pdev)