lkml.org 
[lkml]   [2008]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Drivers for selfmade hardware
On Sun, 29 Jun 2008 21:47:52 +0200 Michael Buesch <mb@bu3sch.de> wrote:

> I'm wondering what the policy is for selfmade hardware
> or other hardware where only a few pieces exist. Is it desired
> to get drivers for this kind of hardware merged upstream into the
> mainline kernel?
>
> I have a tiny driver that can be used to drive a modified
> Brooktree 8xx based card in 24-port GPIO mode.
> So the card can be used as a cheap digital PCI GPIO card.
> This hardware can be built with some soldering skills, a tiny
> soldering tip and a few hours of free time.
>
> So what's the policy? Push to mainline or keep as seperate
> patch?
>
> (The following patch is not complete, but just what I have for now
> to show you...)
>
> ...
>
> +#ifdef CONFIG_PM
> +static int btgpio_suspend(struct pci_dev *pdev, pm_message_t state)
> +{
> + struct btgpio *bg = pci_get_drvdata(pdev);
> + unsigned long flags;
> +
> + spin_lock_irqsave(&bg->lock, flags);
> +
> + bg->saved_outen = bgread(BT848_GPIO_OUT_EN);
> + bg->saved_data = bgread(BT848_GPIO_DATA);
> +
> + bgwrite(0, BT848_INT_MASK);
> + bgwrite(~0x0, BT848_INT_STAT);
> + bgwrite(0x0, BT848_GPIO_OUT_EN);
> +
> + spin_unlock_irqrestore(&bg->lock, flags);
> +
> + pci_save_state(pdev);
> + pci_disable_device(pdev);
> + pci_set_power_state(pdev, pci_choose_state(pdev, state));
> +
> + return 0;
> +}
> +
> +static int btgpio_resume(struct pci_dev *pdev)
> +{
> + struct btgpio *bg = pci_get_drvdata(pdev);
> + unsigned long flags;
> + int err;
> +
> + pci_set_power_state(pdev, 0);
> + err = pci_enable_device(pdev);
> + if (err)
> + return err;
> + pci_restore_state(pdev);
> +
> + spin_lock_irqsave(&bg->lock, flags);
> +
> + bgwrite(0, BT848_INT_MASK);
> + bgwrite(0, BT848_GPIO_REG_INP);
> + bgwrite(bg->saved_outen, BT848_GPIO_OUT_EN);
> + bgwrite(bg->saved_data, BT848_GPIO_DATA);
> +
> + spin_unlock_irqrestore(&bg->lock, flags);
> +
> + return 0;
> +}

#else
#define btgpio_suspend NULL
#define btgpio_resume NULL

> +#endif /* CONFIG_PM */
> +
> +static struct pci_device_id btgpio_pci_tbl[] = {
> + { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848) },
> + { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849) },
> + { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878) },
> + { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT879) },
> + { 0, },
> +};
> +MODULE_DEVICE_TABLE(pci, btgpio_pci_tbl);
> +
> +static struct pci_driver btgpio_pci_driver = {
> + .name = "btgpio",
> + .id_table = btgpio_pci_tbl,
> + .probe = btgpio_probe,
> + .remove = btgpio_remove,
> +#ifdef CONFIG_PM

dd

> + .suspend = btgpio_suspend,
> + .resume = btgpio_resume,
> +#endif

dd

> +};
> +



\
 
 \ /
  Last update: 2008-07-10 07:55    [W:0.061 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site