11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * SL811HS register declarations and HCD data structures 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 2004 Psion Teklogix 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 2004 David Brownell 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 2001 Cypress Semiconductor Inc. 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * SL811HS has transfer registers, and control registers. In host/master 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * mode one set of registers is used; in peripheral/slave mode, another. 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - SL11H only has some "A" transfer registers from 0x00-0x04 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - SL811HS also has "B" registers from 0x08-0x0c 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * - SL811S (or HS in slave mode) has four A+B sets, at 00, 10, 20, 30 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811_EP_A(base) ((base) + 0) 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811_EP_B(base) ((base) + 8) 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811_HOST_BUF 0x00 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811_PERIPH_EP0 0x00 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811_PERIPH_EP1 0x10 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811_PERIPH_EP2 0x20 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811_PERIPH_EP3 0x30 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* TRANSFER REGISTERS: host and peripheral sides are similar 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * except for the control models (master vs slave). 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_HOSTCTLREG 0 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HCTLMASK_ARM 0x01 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HCTLMASK_ENABLE 0x02 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HCTLMASK_IN 0x00 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HCTLMASK_OUT 0x04 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HCTLMASK_ISOCH 0x10 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HCTLMASK_AFTERSOF 0x20 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HCTLMASK_TOGGLE 0x40 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HCTLMASK_PREAMBLE 0x80 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_BUFADDRREG 1 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_BUFLNTHREG 2 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_PKTSTATREG 3 /* read */ 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_STATMASK_ACK 0x01 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_STATMASK_ERROR 0x02 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_STATMASK_TMOUT 0x04 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_STATMASK_SEQ 0x08 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_STATMASK_SETUP 0x10 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_STATMASK_OVF 0x20 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_STATMASK_NAK 0x40 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_STATMASK_STALL 0x80 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_PIDEPREG 3 /* write */ 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_SETUP 0xd0 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_IN 0x90 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_OUT 0x10 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_SOF 0x50 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_PREAMBLE 0xc0 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_NAK 0xa0 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_STALL 0xe0 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_DATA0 0x30 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL_DATA1 0xb0 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_XFERCNTREG 4 /* read */ 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_DEVADDRREG 4 /* write */ 621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* CONTROL REGISTERS: host and peripheral are very different. 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_CTLREG1 5 671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_CTL1MASK_SOF_ENA 0x01 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_CTL1MASK_FORCE 0x18 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_CTL1MASK_NORMAL 0x00 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_CTL1MASK_SE0 0x08 /* reset */ 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_CTL1MASK_J 0x10 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_CTL1MASK_K 0x18 /* resume */ 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_CTL1MASK_LSPD 0x20 741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_CTL1MASK_SUSPEND 0x40 751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_IRQ_ENABLE 6 761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_INTMASK_DONE_A 0x01 771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_INTMASK_DONE_B 0x02 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_INTMASK_SOFINTR 0x10 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_INTMASK_INSRMV 0x20 /* to/from SE0 */ 801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_INTMASK_RD 0x40 811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_INTMASK_DP 0x80 /* only in INTSTATREG */ 821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11S_ADDRESS 7 831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 0x08-0x0c are for the B buffer (not in SL11) */ 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_IRQ_STATUS 0x0D /* write to ack */ 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_HWREVREG 0x0E /* read */ 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL11H_HWRMASK_HWREV 0xF0 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_SOFLOWREG 0x0E /* write */ 901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_SOFTMRREG 0x0F /* read */ 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* a write to this register enables SL811HS features. 931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOST flag presumably overrides the chip input signal? 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811HS_CTLREG2 0x0F 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL811HS_CTL2MASK_SOF_MASK 0x3F 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL811HS_CTL2MASK_DSWAP 0x40 981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define SL811HS_CTL2MASK_HOST 0x80 991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811HS_CTL2_INIT (SL811HS_CTL2MASK_HOST | 0x2e) 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* DATA BUFFERS: registers from 0x10..0xff are for data buffers; 1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * that's 240 bytes, which we'll split evenly between A and B sides. 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Only ISO can use more than 64 bytes per packet. 1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (The SL11S has 0x40..0xff for buffers.) 1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define H_MAXPACKET 120 /* bytes in A or B fifos */ 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL11H_DATA_START 0x10 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SL811HS_PACKET_BUF(is_a) ((is_a) \ 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ? SL11H_DATA_START \ 1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds : (SL11H_DATA_START + H_MAXPACKET)) 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*-------------------------------------------------------------------------*/ 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define LOG2_PERIODIC_SIZE 5 /* arbitrary; this matches OHCI */ 1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PERIODIC_SIZE (1 << LOG2_PERIODIC_SIZE) 1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct sl811 { 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spinlock_t lock; 1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *addr_reg; 1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *data_reg; 1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sl811_platform_data *board; 1250511b36399434d49d3a6b58cf49be90d96e66848Greg Kroah-Hartman struct dentry *debug_file; 1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long stat_insrmv; 1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long stat_wake; 1291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long stat_sof; 1301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long stat_a; 1311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long stat_b; 1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long stat_lost; 1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long stat_overrun; 1341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* sw model */ 1361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct timer_list timer; 1371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sl811h_ep *next_periodic; 1381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sl811h_ep *next_async; 1391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sl811h_ep *active_a; 1411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long jiffies_a; 1421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sl811h_ep *active_b; 1431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long jiffies_b; 1441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 port1; 1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 ctrl1, ctrl2, irq_enable; 1471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 frame; 1481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* async schedule: control, bulk */ 1501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head async; 1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* periodic schedule: interrupt, iso */ 1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 load[PERIODIC_SIZE]; 1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sl811h_ep *periodic[PERIODIC_SIZE]; 1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned periodic_count; 1561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline struct sl811 *hcd_to_sl811(struct usb_hcd *hcd) 1591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (struct sl811 *) (hcd->hcd_priv); 1611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline struct usb_hcd *sl811_to_hcd(struct sl811 *sl811) 1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return container_of((void *) sl811, struct usb_hcd, hcd_priv); 1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct sl811h_ep { 1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct usb_host_endpoint *hep; 1701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct usb_device *udev; 1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 defctrl; 1731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 maxpacket; 1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 epnum; 1751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 nextpid; 1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 error_count; 1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 nak_count; 1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 length; /* of current packet */ 1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* periodic schedule */ 1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 period; 1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 branch; 1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u16 load; 1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sl811h_ep *next; 1861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* async schedule */ 1881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head schedule; 1891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*-------------------------------------------------------------------------*/ 1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* These register utilities should work for the SL811S register API too 1941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NOTE: caller must hold sl811->lock. 1951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline u8 sl811_read(struct sl811 *sl811, int reg) 1981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds writeb(reg, sl811->addr_reg); 2001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return readb(sl811->data_reg); 2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline void sl811_write(struct sl811 *sl811, int reg, u8 val) 2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds writeb(reg, sl811->addr_reg); 2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds writeb(val, sl811->data_reg); 2071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline void 2101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldssl811_write_buf(struct sl811 *sl811, int addr, const void *buf, size_t count) 2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds const u8 *data; 2131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *data_reg; 2141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!count) 2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return; 2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds writeb(addr, sl811->addr_reg); 2181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds data = buf; 2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds data_reg = sl811->data_reg; 2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds do { 2221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds writeb(*data++, data_reg); 2231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } while (--count); 2241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline void 2271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldssl811_read_buf(struct sl811 *sl811, int addr, void *buf, size_t count) 2281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u8 *data; 2301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *data_reg; 2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!count) 2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return; 2341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds writeb(addr, sl811->addr_reg); 2351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds data = buf; 2371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds data_reg = sl811->data_reg; 2381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds do { 2391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *data++ = readb(data_reg); 2401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } while (--count); 2411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*-------------------------------------------------------------------------*/ 2441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef PACKET_TRACE 246e45282829a814a7f1e857427f218b21aef012e52Greg Kroah-Hartman# define PACKET pr_debug("sl811: "stuff) 2471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else 2481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds# define PACKET(stuff...) do{}while(0) 2491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 250