Re: hi marek

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Wed, Nov 10, 2010 at 5:07 PM, dylan cristiani
> <d.cristiani@xxxxxxxxxxxx> wrote:
> > On Tue, 9 Nov 2010 19:36:13 +0100
> > Marek Vasut <marek.vasut@xxxxxxxxx> wrote:
> > 
> > > On Tuesday 09 November 2010 18:42:20 dylan cristiani wrote:
> > > > We heard some month ago, about ucb1400 irq passing, via
> > > > ucb1400_platform_data; then you wrote the patch, that is currently
> > > > into mainline; i've a little problem, probably due to my infinite
> > > > ignorance: i'm writing a sort of my_pm.c driver to check whether
> > > > the ac line is plugged or not, check the main battery voltage and
> > > > so on (similar to arch/arm/mach-pxa/sharpsl_pm.c and corgi_pm.c if
> > > > you know it); the problem is that the battery voltages are tied to
> > > > the ucb1400 ADC inputs, and in my_pm.c driver i don't know how to
> > > > find the ucb1400_ts structure address to call the functions i need
> > > > to read these ADC input i.e.:
> > > 
> > > 1) CC lists
> > > 
> > > 2) Can you post the driver source you have ?
> > > 
> > > without seeing the source, I can't help you
> > here it comes but please close your nose before reading....;-)
> > 
> > arch/arm/mach-pxa/nilux_pm.c
> > 
> > /*
> > Â* Based on spitz_pm.c and sharp code.
> > Â*
> > Â* Distributed under term of GPLv2.
> > Â*
> > Â*/
> > 
> > #include <linux/module.h>
> > #include <linux/stat.h>
> > #include <linux/init.h>
> > #include <linux/completion.h>
> > #include <linux/kernel.h>
> > #include <linux/delay.h>
> > #include <linux/gpio.h>
> > //#include <linux/input.h>
> > #include <linux/device.h>
> > #include <linux/interrupt.h>
> > #include <linux/suspend.h>
> > #include <linux/apm-emulation.h>
> > #include <linux/platform_device.h>
> > #include <linux/ucb1400.h>
> > 
> > #include <asm/irq.h>
> > #include <asm/mach-types.h>
> > #include <mach/hardware.h>
> > 
> > #include <mach/pm.h>
> > #include <mach/pxa2xx-regs.h>
> > #include <mach/regs-rtc.h>
> > #include <mach/sharpsl_pm.h>
> > 
> > 
> > #define AC_IN_INT Â Â Â Â Â Â Â 17
> > #define NYLUX_BATT_VOLT Â Â Â Â 1
> > #define NYLUX_STATUS_ACIN Â Â Â 4
> > #define NYLUX_BKUPBATT_TEMP Â Â 2
> > #define NYLUX_CHARGE_STATUS Â Â 3
> > 
> > 
> > static struct ucb1400_ts *ucb;
> > 
> > static void nylux_charger_init(void)
> > {
> > }
> > 
> > static void nylux_charger_exit(void)
> > {
> > }
> > 
> > unsigned long nylux_read_main_battery(void)
> > {
> > // Â Â Âstruct ucb1400_ts *ucb;
> > Â Â Â Âunsigned int voltage = 0;
> > 
> > Â Â Â Âprintk(KERN_INFO "Reading_Main_Battery\n");
> > 
> > Â Â Â Âucb1400_adc_enable(ucb->ac97);
> > 
> > // Â Â Âprintk(KERN_INFO "Post adc_enable\n");
> > 
> > Â Â Â Âmdelay(1);
> > Â Â Â Âvoltage = ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_AD0, 0);
> > Â Â Â Âprintk(KERN_INFO "\nVVVVVVvoltage %d\n", voltage);
> > 
> > Â Â Â Âucb1400_adc_disable(ucb->ac97);
> > 
> > Â Â Â Âreturn voltage;
> > }
> > 
> > unsigned long nylux_read_bkup_battery(void)
> > {
> > // Â Â Âstruct ucb1400_ts *ucb;
> > Â Â Â Âunsigned int voltage;
> > 
> > Â Â Â Âucb1400_adc_enable(ucb->ac97);
> > 
> > Â Â Â Âmdelay(1);
> > Â Â Â Âvoltage = ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_AD1, 0);
> > 
> > Â Â Â Âucb1400_adc_disable(ucb->ac97);
> > Â Â Â Â//printk(KERN_INFO "Battery_bkup value = %d\n", voltage);
> > 
> > Â Â Â Âreturn voltage;
> > }
> > 
> > unsigned long nylux_charge_status(void)
> > {
> > // Â Â Âstruct ucb1400_ts *ucb;
> > Â Â Â Âunsigned int status;
> > 
> > Â Â Â Â//printk(KERN_INFO "Charge_status\n");
> > Â Â Â Âucb1400_adc_enable(ucb->ac97);
> > Â Â Â Âmdelay(1);
> > Â Â Â Âstatus = ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_AD2, 0);
> > Â Â Â Â//printk(KERN_INFO "Charge status= %d\n", status);
> > Â Â Â Âucb1400_adc_disable(ucb->ac97);
> > 
> > Â Â Â Âreturn status;
> > 
> > }
> > 
> > static unsigned long nylux_read_devdata(int which)
> > {
> > Â Â Â Âunsigned long ret = ~0;
> > 
> > Â Â Â Âswitch (which) {
> > Â Â Â Âcase NYLUX_BATT_VOLT:
> > Â Â Â Â Â Â Â Âret = nylux_read_main_battery();
> > Â Â Â Â Â Â Â Â//printk(KERN_INFO "read_main_battery: %d\n", ret);
> > Â Â Â Â Â Â Â Âbreak;
> > Â Â Â Â//case NYLUX_BKUPBATT_TEMP:
> > Â Â Â Â Â Â Â Â//ret = nylux_read_bkup_battery();
> > Â Â Â Â Â Â Â Â//break;
> > Â Â Â Â//case NYLUX_CHARGE_STATUS:
> > Â Â Â Â Â Â Â Â//ret = nylux_charge_status();
> > Â Â Â Â Â Â Â Â//break;
> > Â Â Â Âcase NYLUX_STATUS_ACIN: {
> > Â Â Â Â Â Â Â Âret = GPLR(AC_IN_INT) & GPIO_bit(AC_IN_INT);
> > Â Â Â Â Â Â Â Â//printk(KERN_INFO "AC_IN = %d\n", ret);
> > Â Â Â Â Â Â Â Â//ret = read_ac_status();
> > Â Â Â Â Â Â Â Â//printk(KERN_INFO "read_ac_status: %d\n", ret);
> > Â Â Â Â Â Â Â Âbreak;
> > Â Â Â Â}
> > 
> > Â Â Â Âdefault:
> > Â Â Â Â Â Â Â Âret = ~0;
> > Â Â Â Â}
> > 
> > Â Â Â Âreturn ret;
> > 
> > }
> > 
> > //******
> > struct battery_thresh battery_levels[] = {
> > Â Â Â Â{ 550, 100},
> > Â Â Â Â{ 544, Â97},
> > Â Â Â Â{ 541, Â93},
> > Â Â Â Â{ 536, Â88},
> > Â Â Â Â{ 531, Â83},
> > Â Â Â Â{ 526, Â78},
> > Â Â Â Â{ 522, Â73},
> > Â Â Â Â{ 517, Â68},
> > Â Â Â Â{ 514, Â63},
> > Â Â Â Â{ 510, Â58},
> > Â Â Â Â{ 506, Â53},
> > Â Â Â Â{ 503, Â48},
> > Â Â Â Â{ 499, Â43},
> > Â Â Â Â{ 497, Â38},
> > Â Â Â Â{ 495, Â33},
> > Â Â Â Â{ 493, Â28},
> > Â Â Â Â{ 492, Â23},
> > Â Â Â Â{ 491, Â18},
> > Â Â Â Â{ 489, Â13},
> > Â Â Â Â{ 488, Â 8},
> > Â Â Â Â{ 484, Â 3},
> > Â Â Â Â{ 478, Â 0}
> > };
> > 
> > struct sharpsl_charger_machinfo nylux_pm_machinfo = {
> >    Â.init       = nylux_charger_init,
> >    Â.exit       = nylux_charger_exit,
> >    Â.gpio_acin    Â= AC_IN_INT,
> >    Â.read_devdata   = nylux_read_devdata,
> >    Â.discharge    Â= 0,
> > Â Â Â Â.discharge1 Â Â Â = 0,
> >    Â.charge      = 0,
> >    Â.measure_temp   = 0,
> >    Â.presuspend    = 0,
> >    Â.postsuspend   Â= 0,
> >    Â.charger_wakeup  = 0,
> >    Â.should_wakeup  Â= 0,
> >    Â.bat_levels    = 22,
> > Â Â Â Â.bat_levels_noac Â= battery_levels,
> > Â Â Â Â.bat_levels_acin Â= 0,
> > Â Â Â Â.status_high_acin = 510,
> > Â Â Â Â.status_low_acin Â= 490,
> > Â Â Â Â.status_high_noac = 510,
> > Â Â Â Â.status_low_noac Â= 490,
> >    Â.charge_on_volt  = 0,
> >    Â.charge_on_temp  = 0,
> > Â Â Â Â.charge_acin_high = 0,
> > Â Â Â Â.charge_acin_low Â= 0,
> > Â Â Â Â.fatal_acin_volt Â= 0,
> > Â Â Â Â.fatal_noacin_volt = 0,
> > 
> >    Â.batfull_irq   Â= 1
> > };
> > 
> > 
> > /*
> > static int __init collie_pm_ucb_add(struct ucb1x00_dev *pdev)
> > {
> > Â Â Â Âsharpsl_pm.machinfo = &nylux_pm_machinfo;
> > Â Â Â Âucb = pdev->ucb;
> > Â Â Â Âreturn 0;
> > }
> > 
> > static struct ucb1x00_driver collie_pm_ucb_driver = {
> >    Â.add      Â= collie_pm_ucb_add,
> > };
> > */
> > 
> > static struct platform_device *nyluxpm_device;
> > 
> > static int __devinit nyluxpm_init(void)
> > {
> > Â Â Â Âint ret;
> > 
> > Â Â Â Ânyluxpm_device = platform_device_alloc("sharpsl-pm", -1);
> > Â Â Â Âif (!nyluxpm_device)
> > Â Â Â Â Â Â Â Âreturn -ENOMEM;
> > 
> > Â Â Â Ânyluxpm_device->dev.platform_data = &nylux_pm_machinfo;
> > Â Â Â Âret = platform_device_add(nyluxpm_device);
> > 
> > Â Â Â Âif (ret)
> > Â Â Â Â Â Â Â Âplatform_device_put(nyluxpm_device);
> > 
> > // Â Â Âif (!ret)
> > // Â Â Â Â Â Â Âret = ucb1x00_register_driver(&collie_pm_ucb_driver);
> > 
> > Â Â Â Âreturn ret;
> > }
> > 
> > static void nyluxpm_exit(void)
> > {
> > // Â Â Âucb1x00_unregister_driver(&collie_pm_ucb_driver);
> > Â Â Â Âplatform_device_unregister(nyluxpm_device);
> > }
> > 
> > module_init(nyluxpm_init);
> > module_exit(nyluxpm_exit);
> > 
> > 
> > thanks
> > dylan
> > 
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> > 
> 
> You should append your power driver into drivers/power directory.
> There's an example of colie_battery.c. It's also based on udc.

That's basically what I said a few lines above ;-)

btw I think he's also intermixing ucb1x00 (ucb < 1400) and ucb1400
> 
> Thanks
> Haojian

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux