aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2009-05-02 10:29:50 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:21:02 -0400
commit6f8bee9b104465a881f7e8acd5cbd3e6a0730759 (patch)
tree80feb7e141692ab945b36e5aed22666ce6ac5abf /drivers
parentea3b73dc13d87d92e805f439f3d7bfcb5865db06 (diff)
V4L/DVB (11765): cx23885: Add generic functions for driving GPIO's
The GPIO's on the product can be in one of three places. To date we've mainly used the GPIO's on the bridge itself, and once on the encoder. Rather than having the complexity of multiple GPIO writes/reads from isolated placed in the driver we'll route them through this function, so we can make intelligent decisions about 1) Where the GPIO lives and 2) Whether it conflicts (based on board) with some other function to avoid bugs. Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Michael Krufky <mkrufky@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c82
-rw-r--r--drivers/media/video/cx23885/cx23885.h16
2 files changed, 98 insertions, 0 deletions
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index 9e4d37eb918e..eb5e3412d39b 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -1733,6 +1733,88 @@ out:
1733 return IRQ_RETVAL(handled); 1733 return IRQ_RETVAL(handled);
1734} 1734}
1735 1735
1736int encoder_on_portb(struct cx23885_dev *dev)
1737{
1738 return cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER;
1739}
1740
1741int encoder_on_portc(struct cx23885_dev *dev)
1742{
1743 return cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER;
1744}
1745
1746/* Mask represents 32 different GPIOs, GPIO's are split into multiple
1747 * registers depending on the board configuration (and whether the
1748 * 417 encoder (wi it's own GPIO's) are present. Each GPIO bit will
1749 * be pushed into the correct hardware register, regardless of the
1750 * physical location. Certain registers are shared so we sanity check
1751 * and report errors if we think we're tampering with a GPIo that might
1752 * be assigned to the encoder (and used for the host bus).
1753 *
1754 * GPIO 2 thru 0 - On the cx23885 bridge
1755 * GPIO 18 thru 3 - On the cx23417 host bus interface
1756 * GPIO 23 thru 19 - On the cx25840 a/v core
1757 */
1758void cx23885_gpio_set(struct cx23885_dev *dev, u32 mask)
1759{
1760 if (mask & 0x7)
1761 cx_set(GP0_IO, mask & 0x7);
1762
1763 if (mask & 0x0007fff8) {
1764 if (encoder_on_portb(dev) || encoder_on_portc(dev))
1765 printk(KERN_ERR
1766 "%s: Setting GPIO on encoder ports\n",
1767 dev->name);
1768 cx_set(MC417_RWD, (mask & 0x0007fff8) >> 3);
1769 }
1770
1771 /* TODO: 23-19 */
1772 if (mask & 0x00f80000)
1773 printk(KERN_INFO "%s: Unsupported\n", dev->name);
1774}
1775
1776void cx23885_gpio_clear(struct cx23885_dev *dev, u32 mask)
1777{
1778 if (mask & 0x00000007)
1779 cx_clear(GP0_IO, mask & 0x7);
1780
1781 if (mask & 0x0007fff8) {
1782 if (encoder_on_portb(dev) || encoder_on_portc(dev))
1783 printk(KERN_ERR
1784 "%s: Clearing GPIO moving on encoder ports\n",
1785 dev->name);
1786 cx_clear(MC417_RWD, (mask & 0x7fff8) >> 3);
1787 }
1788
1789 /* TODO: 23-19 */
1790 if (mask & 0x00f80000)
1791 printk(KERN_INFO "%s: Unsupported\n", dev->name);
1792}
1793
1794void cx23885_gpio_enable(struct cx23885_dev *dev, u32 mask, int asoutput)
1795{
1796 if ((mask & 0x00000007) && asoutput)
1797 cx_set(GP0_IO, (mask & 0x7) << 16);
1798 else if ((mask & 0x00000007) && !asoutput)
1799 cx_clear(GP0_IO, (mask & 0x7) << 16);
1800
1801 if (mask & 0x0007fff8) {
1802 if (encoder_on_portb(dev) || encoder_on_portc(dev))
1803 printk(KERN_ERR
1804 "%s: Enabling GPIO on encoder ports\n",
1805 dev->name);
1806 }
1807
1808 /* MC417_OEN is active low for output, write 1 for an input */
1809 if ((mask & 0x0007fff8) && asoutput)
1810 cx_clear(MC417_OEN, (mask & 0x7fff8) >> 3);
1811
1812 else if ((mask & 0x0007fff8) && !asoutput)
1813 cx_set(MC417_OEN, (mask & 0x7fff8) >> 3);
1814
1815 /* TODO: 23-19 */
1816}
1817
1736static int __devinit cx23885_initdev(struct pci_dev *pci_dev, 1818static int __devinit cx23885_initdev(struct pci_dev *pci_dev,
1737 const struct pci_device_id *pci_id) 1819 const struct pci_device_id *pci_id)
1738{ 1820{
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h
index 85642831ea8e..d9b03f83fa31 100644
--- a/drivers/media/video/cx23885/cx23885.h
+++ b/drivers/media/video/cx23885/cx23885.h
@@ -72,6 +72,17 @@
72#define CX23885_BOARD_DVBWORLD_2005 16 72#define CX23885_BOARD_DVBWORLD_2005 16
73#define CX23885_BOARD_NETUP_DUAL_DVBS2_CI 17 73#define CX23885_BOARD_NETUP_DUAL_DVBS2_CI 17
74 74
75#define GPIO_0 0x00000001
76#define GPIO_1 0x00000002
77#define GPIO_2 0x00000004
78#define GPIO_3 0x00000008
79#define GPIO_4 0x00000010
80#define GPIO_5 0x00000020
81#define GPIO_6 0x00000040
82#define GPIO_7 0x00000080
83#define GPIO_8 0x00000100
84#define GPIO_9 0x00000200
85
75/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */ 86/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */
76#define CX23885_NORMS (\ 87#define CX23885_NORMS (\
77 V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 | \ 88 V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 | \
@@ -422,6 +433,11 @@ extern int cx23885_restart_queue(struct cx23885_tsport *port,
422extern void cx23885_wakeup(struct cx23885_tsport *port, 433extern void cx23885_wakeup(struct cx23885_tsport *port,
423 struct cx23885_dmaqueue *q, u32 count); 434 struct cx23885_dmaqueue *q, u32 count);
424 435
436extern void cx23885_gpio_set(struct cx23885_dev *dev, u32 mask);
437extern void cx23885_gpio_clear(struct cx23885_dev *dev, u32 mask);
438extern void cx23885_gpio_enable(struct cx23885_dev *dev, u32 mask,
439 int asoutput);
440
425 441
426/* ----------------------------------------------------------- */ 442/* ----------------------------------------------------------- */
427/* cx23885-cards.c */ 443/* cx23885-cards.c */