Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-30 Thread Pavel Machek
On So 30-07-05 10:26:56, Russell King wrote:
> On Mon, Jul 25, 2005 at 08:22:42AM +0200, Pavel Machek wrote:
> > I replaced sharp functions with ucb_1x00 functions this way; I hope I
> > did not mess it up.
> > 
> > diff --git a/arch/arm/mach-sa1100/battery-collie.c 
> > b/arch/arm/mach-sa1100/battery-collie.c
> > --- a/arch/arm/mach-sa1100/battery-collie.c
> > +++ b/arch/arm/mach-sa1100/battery-collie.c
> > -
> > -   ucb1200_set_io(COLLIE_TC35143_GPIO_BBAT_ON, COLLIE_TC35143_IODAT_LOW);
> > -   ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_HIGH);
> > -   voltage = ucb1200_get_adc_value(ADC_REQ_ID, COLLIE_TC35143_ADC_BAT_VOL);
> > +   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_BBAT_ON);
> > +   ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_MBAT_ON, 0);
> > +   voltage = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_VOL, UCB_SYNC);
> 
> This won't work.  You can't pass NULL to functions that take a pointer
> and expect them to work.  Look back at my patch set, at the way the
> ucb1x00-assabet patch does this.

I did some quick hack for now, thanks.
Pavel
-- 
if you have sharp zaurus hardware you don't need... you know my address
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-30 Thread Russell King
On Mon, Jul 25, 2005 at 08:22:42AM +0200, Pavel Machek wrote:
> I replaced sharp functions with ucb_1x00 functions this way; I hope I
> did not mess it up.
> 
> diff --git a/arch/arm/mach-sa1100/battery-collie.c 
> b/arch/arm/mach-sa1100/battery-collie.c
> --- a/arch/arm/mach-sa1100/battery-collie.c
> +++ b/arch/arm/mach-sa1100/battery-collie.c
> -
> - ucb1200_set_io(COLLIE_TC35143_GPIO_BBAT_ON, COLLIE_TC35143_IODAT_LOW);
> - ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_HIGH);
> - voltage = ucb1200_get_adc_value(ADC_REQ_ID, COLLIE_TC35143_ADC_BAT_VOL);
> + ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_BBAT_ON);
> + ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_MBAT_ON, 0);
> + voltage = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_VOL, UCB_SYNC);

This won't work.  You can't pass NULL to functions that take a pointer
and expect them to work.  Look back at my patch set, at the way the
ucb1x00-assabet patch does this.

-- 
Russell King
 Linux kernel2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-26 Thread Pavel Machek
Hi!

> I have similar problems with the corgi battery driver which is probably
> even more of a mess than this. My conclusion is the whole lot needs
> rewriting in a nice fashion before it can be included in mainline. My
> work so far on the corgi code is here:
> 
> http://www.rpsys.net/openzaurus/patches/corgi_power-r24.patch

+void corgikbd_setled_charge(int led_set)
+{
+   if (led_set) 
+   GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
+   else
+   GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
+}

Ugh... GPSR0 / GPCR0 looks _very_ similar :-(. I thought I am seeing
an error.
Pavel

-- 
teflon -- maybe it is a trademark, but it should not be.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-26 Thread Pavel Machek
Hi!

> > #defineSCP_REG_MCR SCP_REG(SCP_MCR)
> > #defineSCP_REG_CDR SCP_REG(SCP_CDR)
> > #defineSCP_REG_CSR SCP_REG(SCP_CSR)
> > #defineSCP_REG_CPR SCP_REG(SCP_CPR)
> > #defineSCP_REG_CCR SCP_REG(SCP_CCR)
> > #defineSCP_REG_IRR SCP_REG(SCP_IRR)
> > #defineSCP_REG_IRM SCP_REG(SCP_IRM)
> > #defineSCP_REG_IMR SCP_REG(SCP_IMR)
> > #defineSCP_REG_ISR SCP_REG(SCP_ISR)
> > #defineSCP_REG_GPCRSCP_REG(SCP_GPCR)
> > #defineSCP_REG_GPWRSCP_REG(SCP_GPWR)
> > #defineSCP_REG_GPRRSCP_REG(SCP_GPRR)
> 
> You'll find the scoop driver deals with the above
> (arch/arm/common/scoop.c).

Thanks.

> > #define FLASH_MEM_BASE 0xe8ffc000
> > #defineFLASH_DATA(adr) (*(volatile unsigned 
> > int*)(FLASH_MEM_BASE+(adr)))
> > #defineFLASH_DATA_F(adr) (*(volatile float32 
> > *)(FLASH_MEM_BASE+(adr)))
> > #define FLASH_MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 )  | ( b << 8 ) 
> > | a )
> > 
> > // AD
> > #define FLASH_AD_MAJIC FLASH_MAGIC_CHG('B','V','A','D')
> > #defineFLASH_AD_MAGIC_ADR  0x30
> > #defineFLASH_AD_DATA_ADR   0x34
> 
> and arch/arm/common/sharpsl_param.c with these.

Hmm, I wonder what it wants there... It seems to read some battery
correction value? 

> > #define IRQ_GPIO_COIRQ_GPIO20
> > #define IRQ_GPIO_AC_IN IRQ_GPIO1
> 
> There will (or if not, there should) be an equivalent in collie.h for
> the above.
> 
> I have similar problems with the corgi battery driver which is probably
> even more of a mess than this. My conclusion is the whole lot needs
> rewriting in a nice fashion before it can be included in mainline. My
> work so far on the corgi code is here:
> 
> http://www.rpsys.net/openzaurus/patches/corgi_power-r24.patch
> http://www.rpsys.net/openzaurus/patches/corgi_power1-r1.patch

I'll comment in separate mail.

> I'm making progress in areas but I'm not sure how much can be shared
> between devices. My plan is to split the above into two sections, a
> battery driver and some power management code. The powermanagement code
> can probably then make mainline. The battery driver still needs a lot of
> work.

It looks pretty similar... on the first look.
Pavel
-- 
teflon -- maybe it is a trademark, but it should not be.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-26 Thread Pavel Machek
Hi!

  #defineSCP_REG_MCR SCP_REG(SCP_MCR)
  #defineSCP_REG_CDR SCP_REG(SCP_CDR)
  #defineSCP_REG_CSR SCP_REG(SCP_CSR)
  #defineSCP_REG_CPR SCP_REG(SCP_CPR)
  #defineSCP_REG_CCR SCP_REG(SCP_CCR)
  #defineSCP_REG_IRR SCP_REG(SCP_IRR)
  #defineSCP_REG_IRM SCP_REG(SCP_IRM)
  #defineSCP_REG_IMR SCP_REG(SCP_IMR)
  #defineSCP_REG_ISR SCP_REG(SCP_ISR)
  #defineSCP_REG_GPCRSCP_REG(SCP_GPCR)
  #defineSCP_REG_GPWRSCP_REG(SCP_GPWR)
  #defineSCP_REG_GPRRSCP_REG(SCP_GPRR)
 
 You'll find the scoop driver deals with the above
 (arch/arm/common/scoop.c).

Thanks.

  #define FLASH_MEM_BASE 0xe8ffc000
  #defineFLASH_DATA(adr) (*(volatile unsigned 
  int*)(FLASH_MEM_BASE+(adr)))
  #defineFLASH_DATA_F(adr) (*(volatile float32 
  *)(FLASH_MEM_BASE+(adr)))
  #define FLASH_MAGIC_CHG(a,b,c,d) ( ( d  24 ) | ( c  16 )  | ( b  8 ) 
  | a )
  
  // AD
  #define FLASH_AD_MAJIC FLASH_MAGIC_CHG('B','V','A','D')
  #defineFLASH_AD_MAGIC_ADR  0x30
  #defineFLASH_AD_DATA_ADR   0x34
 
 and arch/arm/common/sharpsl_param.c with these.

Hmm, I wonder what it wants there... It seems to read some battery
correction value? 

  #define IRQ_GPIO_COIRQ_GPIO20
  #define IRQ_GPIO_AC_IN IRQ_GPIO1
 
 There will (or if not, there should) be an equivalent in collie.h for
 the above.
 
 I have similar problems with the corgi battery driver which is probably
 even more of a mess than this. My conclusion is the whole lot needs
 rewriting in a nice fashion before it can be included in mainline. My
 work so far on the corgi code is here:
 
 http://www.rpsys.net/openzaurus/patches/corgi_power-r24.patch
 http://www.rpsys.net/openzaurus/patches/corgi_power1-r1.patch

I'll comment in separate mail.

 I'm making progress in areas but I'm not sure how much can be shared
 between devices. My plan is to split the above into two sections, a
 battery driver and some power management code. The powermanagement code
 can probably then make mainline. The battery driver still needs a lot of
 work.

It looks pretty similar... on the first look.
Pavel
-- 
teflon -- maybe it is a trademark, but it should not be.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-26 Thread Pavel Machek
Hi!

 I have similar problems with the corgi battery driver which is probably
 even more of a mess than this. My conclusion is the whole lot needs
 rewriting in a nice fashion before it can be included in mainline. My
 work so far on the corgi code is here:
 
 http://www.rpsys.net/openzaurus/patches/corgi_power-r24.patch

+void corgikbd_setled_charge(int led_set)
+{
+   if (led_set) 
+   GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
+   else
+   GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
+}

Ugh... GPSR0 / GPCR0 looks _very_ similar :-(. I thought I am seeing
an error.
Pavel

-- 
teflon -- maybe it is a trademark, but it should not be.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-25 Thread Richard Purdie
On Mon, 2005-07-25 at 07:46 +0200, Pavel Machek wrote:
> I took battery charging code from sharp and placed it in
> arch/arm/mach-sa1100/battery-collie.c (hope that's good place...). It
> still does not link, and will need complete rewrite, but... If you
> have done this already please let me know.
>
> #define CF_BUF_CTRL_BASE 0xF080
> #defineSCP_REG(adr) (*(volatile unsigned 
> short*)(CF_BUF_CTRL_BASE+(adr)))
> 
> #defineSCP_MCR  0x00
> #defineSCP_CDR  0x04
> #defineSCP_CSR  0x08
> #defineSCP_CPR  0x0C
> #defineSCP_CCR  0x10
> #defineSCP_IRR  0x14
> #defineSCP_IRM  0x14
> #defineSCP_IMR  0x18
> #defineSCP_ISR  0x1C
> #defineSCP_GPCR 0x20
> #defineSCP_GPWR 0x24
> #defineSCP_GPRR 0x28
> #defineSCP_REG_MCR SCP_REG(SCP_MCR)
> #defineSCP_REG_CDR SCP_REG(SCP_CDR)
> #defineSCP_REG_CSR SCP_REG(SCP_CSR)
> #defineSCP_REG_CPR SCP_REG(SCP_CPR)
> #defineSCP_REG_CCR SCP_REG(SCP_CCR)
> #defineSCP_REG_IRR SCP_REG(SCP_IRR)
> #defineSCP_REG_IRM SCP_REG(SCP_IRM)
> #defineSCP_REG_IMR SCP_REG(SCP_IMR)
> #defineSCP_REG_ISR SCP_REG(SCP_ISR)
> #defineSCP_REG_GPCRSCP_REG(SCP_GPCR)
> #defineSCP_REG_GPWRSCP_REG(SCP_GPWR)
> #defineSCP_REG_GPRRSCP_REG(SCP_GPRR)

You'll find the scoop driver deals with the above
(arch/arm/common/scoop.c).

> #define FLASH_MEM_BASE 0xe8ffc000
> #defineFLASH_DATA(adr) (*(volatile unsigned 
> int*)(FLASH_MEM_BASE+(adr)))
> #defineFLASH_DATA_F(adr) (*(volatile float32 *)(FLASH_MEM_BASE+(adr)))
> #define FLASH_MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 )  | ( b << 8 ) | 
> a )
> 
> // AD
> #define FLASH_AD_MAJIC FLASH_MAGIC_CHG('B','V','A','D')
> #defineFLASH_AD_MAGIC_ADR  0x30
> #defineFLASH_AD_DATA_ADR   0x34

and arch/arm/common/sharpsl_param.c with these.

> #define IRQ_GPIO_COIRQ_GPIO20
> #define IRQ_GPIO_AC_IN IRQ_GPIO1

There will (or if not, there should) be an equivalent in collie.h for
the above.

I have similar problems with the corgi battery driver which is probably
even more of a mess than this. My conclusion is the whole lot needs
rewriting in a nice fashion before it can be included in mainline. My
work so far on the corgi code is here:

http://www.rpsys.net/openzaurus/patches/corgi_power-r24.patch
http://www.rpsys.net/openzaurus/patches/corgi_power1-r1.patch

I'm making progress in areas but I'm not sure how much can be shared
between devices. My plan is to split the above into two sections, a
battery driver and some power management code. The powermanagement code
can probably then make mainline. The battery driver still needs a lot of
work.

-- 
Richard



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-25 Thread Pavel Machek
Hi!

I took battery charging code from sharp and placed it in
arch/arm/mach-sa1100/battery-collie.c (hope that's good place...). It
still does not link, and will need complete rewrite, but... If you
have done this already please let me know.

/*
 * Battery routines for collie (Sharp Zaurus sl-5500)
 *
 * Copyright (C) 2001  SHARP
 * Copyright 2005 Pavel Machek <[EMAIL PROTECTED]>
 *
 * 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.
 *
 * ChangeLog:
 * 12-Nov-2001 Lineo Japan, Inc.
 * 30-Jul-2002 Lineo Japan, Inc.  for 2.4.18
 */

/* this driver supports the following functions:
 *  - apm_get_power_status
 *  - charge proc
 */


#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 

#include 
#include 
#include 

/* Various strange defines, coming from sharp */

#define COLLIE_TC35143_IODAT_LOW   0  /* set up fs 8k LPF on data  
*/
#define COLLIE_TC35143_IODAT_HIGH  1  /* set up fs 8k LPF off data 
*/

#define COLLIE_TC35143_IODIR_OUTPUT1  /* set up output mode
*/
#define COLLIE_TC35143_IODIR_INPUT 0  /* set up input  mode
*/

/*
 * UCB1200 register 10: ADC control register
 */
#define ADC_SYNC_ENA (1 << 0)
#define ADC_INPUT_MASK (7 << 2)
#define ADC_INPUT_TSPX (0 << 2)
#define ADC_INPUT_TSMX (1 << 2)
#define ADC_INPUT_TSPY (2 << 2)
#define ADC_INPUT_TSMY (3 << 2)
#define ADC_INPUT_AD0 (4 << 2)
#define ADC_INPUT_AD1 (5 << 2)
#define ADC_INPUT_AD2 (6 << 2)
#define ADC_INPUT_AD3 (7 << 2)
#define ADC_START (1 << 7)
#define ADC_ENA (1 << 15)

#define COLLIE_TC35143_ADC_BAT_TMP  ADC_INPUT_AD0 /* BAT TMP   
*/
#define COLLIE_TC35143_ADC_BAT_VOL  ADC_INPUT_AD1 /* MAIN/BACKUP BAT VOL   
*/
#define COLLIE_TC35143_ADC_TC_PRESSURE  ADC_INPUT_AD2 /* TC PRESSURE
   */
#define COLLIE_TC35143_ADC_REMOCON_KEY  ADC_INPUT_AD3 /* REMOCON KEY   
*/


#define CF_BUF_CTRL_BASE 0xF080
#defineSCP_REG(adr) (*(volatile unsigned 
short*)(CF_BUF_CTRL_BASE+(adr)))

#defineSCP_MCR  0x00
#defineSCP_CDR  0x04
#defineSCP_CSR  0x08
#defineSCP_CPR  0x0C
#defineSCP_CCR  0x10
#defineSCP_IRR  0x14
#defineSCP_IRM  0x14
#defineSCP_IMR  0x18
#defineSCP_ISR  0x1C
#defineSCP_GPCR 0x20
#defineSCP_GPWR 0x24
#defineSCP_GPRR 0x28
#defineSCP_REG_MCR SCP_REG(SCP_MCR)
#defineSCP_REG_CDR SCP_REG(SCP_CDR)
#defineSCP_REG_CSR SCP_REG(SCP_CSR)
#defineSCP_REG_CPR SCP_REG(SCP_CPR)
#defineSCP_REG_CCR SCP_REG(SCP_CCR)
#defineSCP_REG_IRR SCP_REG(SCP_IRR)
#defineSCP_REG_IRM SCP_REG(SCP_IRM)
#defineSCP_REG_IMR SCP_REG(SCP_IMR)
#defineSCP_REG_ISR SCP_REG(SCP_ISR)
#defineSCP_REG_GPCRSCP_REG(SCP_GPCR)
#defineSCP_REG_GPWRSCP_REG(SCP_GPWR)
#defineSCP_REG_GPRRSCP_REG(SCP_GPRR)

#define FLASH_MEM_BASE 0xe8ffc000
#defineFLASH_DATA(adr) (*(volatile unsigned int*)(FLASH_MEM_BASE+(adr)))
#defineFLASH_DATA_F(adr) (*(volatile float32 *)(FLASH_MEM_BASE+(adr)))
#define FLASH_MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 )  | ( b << 8 ) | a )

// AD
#define FLASH_AD_MAJIC FLASH_MAGIC_CHG('B','V','A','D')
#defineFLASH_AD_MAGIC_ADR  0x30
#defineFLASH_AD_DATA_ADR   0x34

#define IRQ_GPIO_COIRQ_GPIO20
#define IRQ_GPIO_AC_IN IRQ_GPIO1

//#define DEBUG 1
#ifdef DEBUG
#define DPRINTK(x, args...)  printk(__FUNCTION__ ": " x,##args)
#define DPRINTK2(x, args...)  printk(__FUNCTION__ ": " x,##args)
#else
#define DPRINTK(x, args...)   if ( msglevel > 1 )   printk(x,##args);
#define DPRINTK2(x, args...)  if ( msglevel > 0 )   printk(x,##args);
#endif




/*** prototype 
*/
int collie_read_MainBattery(void);
int collie_read_BackBattery(void);
int collie_read_Temp(void);
int collie_check_temp(void);
int collie_check_voltage(void);
static void collie_charge_on(void);
static void collie_charge_off(void);
int set_led_status(int which,int status);
int GetMainLevel( int Volt );
int GetBackLevel( int Volt );
int collie_get_main_battery(void);
unsigned short GetBackupBatteryAD(void);
int suspend_collie_read_Temp(void);

/*** extern 
***/

Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-25 Thread Pavel Machek
Hi!

> I took battery charging code from sharp and placed it in
> arch/arm/mach-sa1100/battery-collie.c (hope that's good place...). It
> still does not link, and will need complete rewrite, but... If you
> have done this already please let me know.

I replaced sharp functions with ucb_1x00 functions this way; I hope I
did not mess it up.

diff --git a/arch/arm/mach-sa1100/battery-collie.c 
b/arch/arm/mach-sa1100/battery-collie.c
--- a/arch/arm/mach-sa1100/battery-collie.c
+++ b/arch/arm/mach-sa1100/battery-collie.c
@@ -54,9 +54,6 @@
 
 /* Various strange defines, coming from sharp */
 
-#define COLLIE_TC35143_IODAT_LOW   0  /* set up fs 8k LPF on data  
*/
-#define COLLIE_TC35143_IODAT_HIGH  1  /* set up fs 8k LPF off data 
*/
-
 #define COLLIE_TC35143_IODIR_OUTPUT1  /* set up output mode
*/
 #define COLLIE_TC35143_IODIR_INPUT 0  /* set up input  mode
*/
 
@@ -226,13 +223,8 @@ static struct miscdevice battery_device 
 
 #define ADC_REQ_ID (u32)(_device)
 
-#ifdef CONFIG_COLLIE_TR0
-#define CHARGE_ON()ucb1200_set_io(COLLIE_TC35143_GPIO_CHRG_ON, 
COLLIE_TC35143_IODAT_HIGH)
-#define CHARGE_OFF()   ucb1200_set_io(COLLIE_TC35143_GPIO_CHRG_ON, 
COLLIE_TC35143_IODAT_LOW)
-#else
 #define CHARGE_ON()SCP_REG_GPWR |= COLLIE_SCP_CHARGE_ON
 #define CHARGE_OFF()   SCP_REG_GPWR &= ~COLLIE_SCP_CHARGE_ON
-#endif
 
 #define CHARGE_LED_ON()printk("charger on\n");
 #define CHARGE_LED_OFF()   printk("charger off\n");
@@ -540,9 +532,6 @@ int GetMainChargePercent( int Volt )
 /*** get adc 
*/
 int collie_get_main_battery(void)
 {
-#ifdef CONFIG_COLLIE_TR0
-   return  COLLIE_BATTERY_STATUS_HIGH;
-#else
int i = 0;
 
MainCntWk++;
@@ -570,8 +559,6 @@ int collie_get_main_battery(void)
  DPRINTK("MainCntWk = %d\n",MainCntWk);
}
return collie_main_battery;
-
-#endif
 }
 
 
@@ -617,14 +604,13 @@ int collie_read_MainBattery(void)
 {
int voltage;
 
-
-   ucb1200_set_io(COLLIE_TC35143_GPIO_BBAT_ON, COLLIE_TC35143_IODAT_LOW);
-   ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_HIGH);
-   voltage = ucb1200_get_adc_value(ADC_REQ_ID, COLLIE_TC35143_ADC_BAT_VOL);
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_BBAT_ON);
+   ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_MBAT_ON, 0);
+   voltage = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_VOL, UCB_SYNC);
if ( battery_off_flag )
  voltage = -1;
-   ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_LOW);
 
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_MBAT_ON);
battery_off_flag = 0;
 
DPRINTK("adc = %d\n",voltage);
@@ -641,13 +627,13 @@ int collie_read_BackBattery(void)
 {
int voltage;
 
-   ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_LOW);
-   ucb1200_set_io(COLLIE_TC35143_GPIO_BBAT_ON, COLLIE_TC35143_IODAT_HIGH);
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_MBAT_ON);
+   ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_BBAT_ON, 0);
mdelay(3);
-   voltage = ucb1200_get_adc_value(ADC_REQ_ID, COLLIE_TC35143_ADC_BAT_VOL);
+   voltage = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_VOL, UCB_SYNC);
if ( battery_off_flag )
  voltage = -1;
-   ucb1200_set_io(COLLIE_TC35143_GPIO_BBAT_ON, COLLIE_TC35143_IODAT_LOW);
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_BBAT_ON);
 
battery_off_flag = 0;
return voltage;
@@ -657,12 +643,12 @@ int collie_read_Temp(void)
 {
int voltage;
 
-
-   ucb1200_set_io(COLLIE_TC35143_GPIO_TMP_ON, COLLIE_TC35143_IODAT_HIGH);
-   voltage = ucb1200_get_adc_value(ADC_REQ_ID, COLLIE_TC35143_ADC_BAT_TMP);
+   ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_TMP_ON, 0);
+   voltage = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_TMP, UCB_SYNC);
if ( battery_off_flag )
  voltage = -1;
-   ucb1200_set_io(COLLIE_TC35143_GPIO_TMP_ON, COLLIE_TC35143_IODAT_LOW);
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_TMP_ON);
+
 
battery_off_flag = 0;
return voltage;
@@ -722,14 +708,12 @@ int suspend_collie_read_Temp(void)
 {
   int temp;
 
-  ucb1200_set_io(COLLIE_TC35143_GPIO_TMP_ON, COLLIE_TC35143_IODAT_HIGH);
+  ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_TMP_ON, 0);
   udelay(700);
-  temp = suspend_read_adc((int), COLLIE_TC35143_ADC_BAT_TMP);
-  ucb1200_set_io(COLLIE_TC35143_GPIO_TMP_ON, COLLIE_TC35143_IODAT_LOW);
+  temp = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_TMP, UCB_SYNC);
+  ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_TMP_ON);
 
   printk("suspend temp = %d\n",temp);
-
-
   return temp;
 }
 
@@ -738,10 +722,11 @@ unsigned short suspend_collie_read_MainB
 {
   int temp;
 
-  ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_HIGH);
+  ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_MBAT_ON, 0);
   

Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-25 Thread Pavel Machek
Hi!

 I took battery charging code from sharp and placed it in
 arch/arm/mach-sa1100/battery-collie.c (hope that's good place...). It
 still does not link, and will need complete rewrite, but... If you
 have done this already please let me know.

I replaced sharp functions with ucb_1x00 functions this way; I hope I
did not mess it up.

diff --git a/arch/arm/mach-sa1100/battery-collie.c 
b/arch/arm/mach-sa1100/battery-collie.c
--- a/arch/arm/mach-sa1100/battery-collie.c
+++ b/arch/arm/mach-sa1100/battery-collie.c
@@ -54,9 +54,6 @@
 
 /* Various strange defines, coming from sharp */
 
-#define COLLIE_TC35143_IODAT_LOW   0  /* set up fs 8k LPF on data  
*/
-#define COLLIE_TC35143_IODAT_HIGH  1  /* set up fs 8k LPF off data 
*/
-
 #define COLLIE_TC35143_IODIR_OUTPUT1  /* set up output mode
*/
 #define COLLIE_TC35143_IODIR_INPUT 0  /* set up input  mode
*/
 
@@ -226,13 +223,8 @@ static struct miscdevice battery_device 
 
 #define ADC_REQ_ID (u32)(battery_device)
 
-#ifdef CONFIG_COLLIE_TR0
-#define CHARGE_ON()ucb1200_set_io(COLLIE_TC35143_GPIO_CHRG_ON, 
COLLIE_TC35143_IODAT_HIGH)
-#define CHARGE_OFF()   ucb1200_set_io(COLLIE_TC35143_GPIO_CHRG_ON, 
COLLIE_TC35143_IODAT_LOW)
-#else
 #define CHARGE_ON()SCP_REG_GPWR |= COLLIE_SCP_CHARGE_ON
 #define CHARGE_OFF()   SCP_REG_GPWR = ~COLLIE_SCP_CHARGE_ON
-#endif
 
 #define CHARGE_LED_ON()printk(charger on\n);
 #define CHARGE_LED_OFF()   printk(charger off\n);
@@ -540,9 +532,6 @@ int GetMainChargePercent( int Volt )
 /*** get adc 
*/
 int collie_get_main_battery(void)
 {
-#ifdef CONFIG_COLLIE_TR0
-   return  COLLIE_BATTERY_STATUS_HIGH;
-#else
int i = 0;
 
MainCntWk++;
@@ -570,8 +559,6 @@ int collie_get_main_battery(void)
  DPRINTK(MainCntWk = %d\n,MainCntWk);
}
return collie_main_battery;
-
-#endif
 }
 
 
@@ -617,14 +604,13 @@ int collie_read_MainBattery(void)
 {
int voltage;
 
-
-   ucb1200_set_io(COLLIE_TC35143_GPIO_BBAT_ON, COLLIE_TC35143_IODAT_LOW);
-   ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_HIGH);
-   voltage = ucb1200_get_adc_value(ADC_REQ_ID, COLLIE_TC35143_ADC_BAT_VOL);
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_BBAT_ON);
+   ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_MBAT_ON, 0);
+   voltage = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_VOL, UCB_SYNC);
if ( battery_off_flag )
  voltage = -1;
-   ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_LOW);
 
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_MBAT_ON);
battery_off_flag = 0;
 
DPRINTK(adc = %d\n,voltage);
@@ -641,13 +627,13 @@ int collie_read_BackBattery(void)
 {
int voltage;
 
-   ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_LOW);
-   ucb1200_set_io(COLLIE_TC35143_GPIO_BBAT_ON, COLLIE_TC35143_IODAT_HIGH);
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_MBAT_ON);
+   ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_BBAT_ON, 0);
mdelay(3);
-   voltage = ucb1200_get_adc_value(ADC_REQ_ID, COLLIE_TC35143_ADC_BAT_VOL);
+   voltage = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_VOL, UCB_SYNC);
if ( battery_off_flag )
  voltage = -1;
-   ucb1200_set_io(COLLIE_TC35143_GPIO_BBAT_ON, COLLIE_TC35143_IODAT_LOW);
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_BBAT_ON);
 
battery_off_flag = 0;
return voltage;
@@ -657,12 +643,12 @@ int collie_read_Temp(void)
 {
int voltage;
 
-
-   ucb1200_set_io(COLLIE_TC35143_GPIO_TMP_ON, COLLIE_TC35143_IODAT_HIGH);
-   voltage = ucb1200_get_adc_value(ADC_REQ_ID, COLLIE_TC35143_ADC_BAT_TMP);
+   ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_TMP_ON, 0);
+   voltage = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_TMP, UCB_SYNC);
if ( battery_off_flag )
  voltage = -1;
-   ucb1200_set_io(COLLIE_TC35143_GPIO_TMP_ON, COLLIE_TC35143_IODAT_LOW);
+   ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_TMP_ON);
+
 
battery_off_flag = 0;
return voltage;
@@ -722,14 +708,12 @@ int suspend_collie_read_Temp(void)
 {
   int temp;
 
-  ucb1200_set_io(COLLIE_TC35143_GPIO_TMP_ON, COLLIE_TC35143_IODAT_HIGH);
+  ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_TMP_ON, 0);
   udelay(700);
-  temp = suspend_read_adc((int)temp, COLLIE_TC35143_ADC_BAT_TMP);
-  ucb1200_set_io(COLLIE_TC35143_GPIO_TMP_ON, COLLIE_TC35143_IODAT_LOW);
+  temp = ucb1x00_adc_read(NULL, COLLIE_TC35143_ADC_BAT_TMP, UCB_SYNC);
+  ucb1x00_io_write(NULL, 0, COLLIE_TC35143_GPIO_TMP_ON);
 
   printk(suspend temp = %d\n,temp);
-
-
   return temp;
 }
 
@@ -738,10 +722,11 @@ unsigned short suspend_collie_read_MainB
 {
   int temp;
 
-  ucb1200_set_io(COLLIE_TC35143_GPIO_MBAT_ON, COLLIE_TC35143_IODAT_HIGH);
+  ucb1x00_io_write(NULL, COLLIE_TC35143_GPIO_MBAT_ON, 0);
   

[warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-25 Thread Pavel Machek
Hi!

I took battery charging code from sharp and placed it in
arch/arm/mach-sa1100/battery-collie.c (hope that's good place...). It
still does not link, and will need complete rewrite, but... If you
have done this already please let me know.

/*
 * Battery routines for collie (Sharp Zaurus sl-5500)
 *
 * Copyright (C) 2001  SHARP
 * Copyright 2005 Pavel Machek [EMAIL PROTECTED]
 *
 * 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.
 *
 * ChangeLog:
 * 12-Nov-2001 Lineo Japan, Inc.
 * 30-Jul-2002 Lineo Japan, Inc.  for 2.4.18
 */

/* this driver supports the following functions:
 *  - apm_get_power_status
 *  - charge proc
 */


#include linux/config.h
#include linux/module.h

#include linux/poll.h
#include linux/types.h
#include linux/stddef.h
#include linux/timer.h
#include linux/fcntl.h
#include linux/stat.h
#include linux/proc_fs.h
#include linux/miscdevice.h
#include linux/init.h
#include linux/sched.h
#include linux/pm.h
#include linux/kernel.h
#include linux/smp_lock.h
#include linux/apm_bios.h
#include linux/delay.h

#include asm/hardware.h
#include asm/irq.h
#include asm/mach/irq.h

#include asm/hardware/scoop.h
#include asm/arch/ucb1x00.h
#include asm/arch/collie.h

/* Various strange defines, coming from sharp */

#define COLLIE_TC35143_IODAT_LOW   0  /* set up fs 8k LPF on data  
*/
#define COLLIE_TC35143_IODAT_HIGH  1  /* set up fs 8k LPF off data 
*/

#define COLLIE_TC35143_IODIR_OUTPUT1  /* set up output mode
*/
#define COLLIE_TC35143_IODIR_INPUT 0  /* set up input  mode
*/

/*
 * UCB1200 register 10: ADC control register
 */
#define ADC_SYNC_ENA (1  0)
#define ADC_INPUT_MASK (7  2)
#define ADC_INPUT_TSPX (0  2)
#define ADC_INPUT_TSMX (1  2)
#define ADC_INPUT_TSPY (2  2)
#define ADC_INPUT_TSMY (3  2)
#define ADC_INPUT_AD0 (4  2)
#define ADC_INPUT_AD1 (5  2)
#define ADC_INPUT_AD2 (6  2)
#define ADC_INPUT_AD3 (7  2)
#define ADC_START (1  7)
#define ADC_ENA (1  15)

#define COLLIE_TC35143_ADC_BAT_TMP  ADC_INPUT_AD0 /* BAT TMP   
*/
#define COLLIE_TC35143_ADC_BAT_VOL  ADC_INPUT_AD1 /* MAIN/BACKUP BAT VOL   
*/
#define COLLIE_TC35143_ADC_TC_PRESSURE  ADC_INPUT_AD2 /* TC PRESSURE
   */
#define COLLIE_TC35143_ADC_REMOCON_KEY  ADC_INPUT_AD3 /* REMOCON KEY   
*/


#define CF_BUF_CTRL_BASE 0xF080
#defineSCP_REG(adr) (*(volatile unsigned 
short*)(CF_BUF_CTRL_BASE+(adr)))

#defineSCP_MCR  0x00
#defineSCP_CDR  0x04
#defineSCP_CSR  0x08
#defineSCP_CPR  0x0C
#defineSCP_CCR  0x10
#defineSCP_IRR  0x14
#defineSCP_IRM  0x14
#defineSCP_IMR  0x18
#defineSCP_ISR  0x1C
#defineSCP_GPCR 0x20
#defineSCP_GPWR 0x24
#defineSCP_GPRR 0x28
#defineSCP_REG_MCR SCP_REG(SCP_MCR)
#defineSCP_REG_CDR SCP_REG(SCP_CDR)
#defineSCP_REG_CSR SCP_REG(SCP_CSR)
#defineSCP_REG_CPR SCP_REG(SCP_CPR)
#defineSCP_REG_CCR SCP_REG(SCP_CCR)
#defineSCP_REG_IRR SCP_REG(SCP_IRR)
#defineSCP_REG_IRM SCP_REG(SCP_IRM)
#defineSCP_REG_IMR SCP_REG(SCP_IMR)
#defineSCP_REG_ISR SCP_REG(SCP_ISR)
#defineSCP_REG_GPCRSCP_REG(SCP_GPCR)
#defineSCP_REG_GPWRSCP_REG(SCP_GPWR)
#defineSCP_REG_GPRRSCP_REG(SCP_GPRR)

#define FLASH_MEM_BASE 0xe8ffc000
#defineFLASH_DATA(adr) (*(volatile unsigned int*)(FLASH_MEM_BASE+(adr)))
#defineFLASH_DATA_F(adr) (*(volatile float32 *)(FLASH_MEM_BASE+(adr)))
#define FLASH_MAGIC_CHG(a,b,c,d) ( ( d  24 ) | ( c  16 )  | ( b  8 ) | a )

// AD
#define FLASH_AD_MAJIC FLASH_MAGIC_CHG('B','V','A','D')
#defineFLASH_AD_MAGIC_ADR  0x30
#defineFLASH_AD_DATA_ADR   0x34

#define IRQ_GPIO_COIRQ_GPIO20
#define IRQ_GPIO_AC_IN IRQ_GPIO1

//#define DEBUG 1
#ifdef DEBUG
#define DPRINTK(x, args...)  printk(__FUNCTION__ :  x,##args)
#define DPRINTK2(x, args...)  printk(__FUNCTION__ :  x,##args)
#else
#define DPRINTK(x, args...)   if ( msglevel  1 )   printk(x,##args);
#define DPRINTK2(x, args...)  if ( msglevel  0 )   printk(x,##args);
#endif




/*** prototype 
*/
int collie_read_MainBattery(void);
int collie_read_BackBattery(void);
int collie_read_Temp(void);
int collie_check_temp(void);
int collie_check_voltage(void);
static void collie_charge_on(void);
static void collie_charge_off(void);
int 

Re: [warning: ugly, FYI] battery charging support for sharp sl-5500

2005-07-25 Thread Richard Purdie
On Mon, 2005-07-25 at 07:46 +0200, Pavel Machek wrote:
 I took battery charging code from sharp and placed it in
 arch/arm/mach-sa1100/battery-collie.c (hope that's good place...). It
 still does not link, and will need complete rewrite, but... If you
 have done this already please let me know.

 #define CF_BUF_CTRL_BASE 0xF080
 #defineSCP_REG(adr) (*(volatile unsigned 
 short*)(CF_BUF_CTRL_BASE+(adr)))
 
 #defineSCP_MCR  0x00
 #defineSCP_CDR  0x04
 #defineSCP_CSR  0x08
 #defineSCP_CPR  0x0C
 #defineSCP_CCR  0x10
 #defineSCP_IRR  0x14
 #defineSCP_IRM  0x14
 #defineSCP_IMR  0x18
 #defineSCP_ISR  0x1C
 #defineSCP_GPCR 0x20
 #defineSCP_GPWR 0x24
 #defineSCP_GPRR 0x28
 #defineSCP_REG_MCR SCP_REG(SCP_MCR)
 #defineSCP_REG_CDR SCP_REG(SCP_CDR)
 #defineSCP_REG_CSR SCP_REG(SCP_CSR)
 #defineSCP_REG_CPR SCP_REG(SCP_CPR)
 #defineSCP_REG_CCR SCP_REG(SCP_CCR)
 #defineSCP_REG_IRR SCP_REG(SCP_IRR)
 #defineSCP_REG_IRM SCP_REG(SCP_IRM)
 #defineSCP_REG_IMR SCP_REG(SCP_IMR)
 #defineSCP_REG_ISR SCP_REG(SCP_ISR)
 #defineSCP_REG_GPCRSCP_REG(SCP_GPCR)
 #defineSCP_REG_GPWRSCP_REG(SCP_GPWR)
 #defineSCP_REG_GPRRSCP_REG(SCP_GPRR)

You'll find the scoop driver deals with the above
(arch/arm/common/scoop.c).

 #define FLASH_MEM_BASE 0xe8ffc000
 #defineFLASH_DATA(adr) (*(volatile unsigned 
 int*)(FLASH_MEM_BASE+(adr)))
 #defineFLASH_DATA_F(adr) (*(volatile float32 *)(FLASH_MEM_BASE+(adr)))
 #define FLASH_MAGIC_CHG(a,b,c,d) ( ( d  24 ) | ( c  16 )  | ( b  8 ) | 
 a )
 
 // AD
 #define FLASH_AD_MAJIC FLASH_MAGIC_CHG('B','V','A','D')
 #defineFLASH_AD_MAGIC_ADR  0x30
 #defineFLASH_AD_DATA_ADR   0x34

and arch/arm/common/sharpsl_param.c with these.

 #define IRQ_GPIO_COIRQ_GPIO20
 #define IRQ_GPIO_AC_IN IRQ_GPIO1

There will (or if not, there should) be an equivalent in collie.h for
the above.

I have similar problems with the corgi battery driver which is probably
even more of a mess than this. My conclusion is the whole lot needs
rewriting in a nice fashion before it can be included in mainline. My
work so far on the corgi code is here:

http://www.rpsys.net/openzaurus/patches/corgi_power-r24.patch
http://www.rpsys.net/openzaurus/patches/corgi_power1-r1.patch

I'm making progress in areas but I'm not sure how much can be shared
between devices. My plan is to split the above into two sections, a
battery driver and some power management code. The powermanagement code
can probably then make mainline. The battery driver still needs a lot of
work.

-- 
Richard



-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/