本文整理汇总了C++中readw函数的典型用法代码示例。如果您正苦于以下问题:C++ readw函数的具体用法?C++ readw怎么用?C++ readw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readw函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtltool_ioctl
int rtltool_ioctl(struct rtl8168_private *tp, struct ifreq *ifr)
{
struct rtltool_cmd my_cmd;
unsigned long flags;
int ret;
if (copy_from_user(&my_cmd, ifr->ifr_data, sizeof(my_cmd)))
return -EFAULT;
ret = 0;
switch (my_cmd.cmd) {
case RTLTOOL_READ_MAC:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (my_cmd.len==1)
my_cmd.data = readb(tp->mmio_addr+my_cmd.offset);
else if (my_cmd.len==2)
my_cmd.data = readw(tp->mmio_addr+(my_cmd.offset&~1));
else if (my_cmd.len==4)
my_cmd.data = readl(tp->mmio_addr+(my_cmd.offset&~3));
else {
ret = -EOPNOTSUPP;
break;
}
if (copy_to_user(ifr->ifr_data, &my_cmd, sizeof(my_cmd))) {
ret = -EFAULT;
break;
}
break;
case RTLTOOL_WRITE_MAC:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (my_cmd.len==1)
writeb(my_cmd.data, tp->mmio_addr+my_cmd.offset);
else if (my_cmd.len==2)
writew(my_cmd.data, tp->mmio_addr+(my_cmd.offset&~1));
else if (my_cmd.len==4)
writel(my_cmd.data, tp->mmio_addr+(my_cmd.offset&~3));
else {
ret = -EOPNOTSUPP;
break;
}
break;
case RTLTOOL_READ_PHY:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
spin_lock_irqsave(&tp->phy_lock, flags);
my_cmd.data = mdio_read(tp, my_cmd.offset);
spin_unlock_irqrestore(&tp->phy_lock, flags);
if (copy_to_user(ifr->ifr_data, &my_cmd, sizeof(my_cmd))) {
ret = -EFAULT;
break;
}
break;
case RTLTOOL_WRITE_PHY:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
spin_lock_irqsave(&tp->phy_lock, flags);
mdio_write(tp, my_cmd.offset, my_cmd.data);
spin_unlock_irqrestore(&tp->phy_lock, flags);
break;
case RTLTOOL_READ_EPHY:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
my_cmd.data = rtl8168_ephy_read(tp->mmio_addr, my_cmd.offset);
if (copy_to_user(ifr->ifr_data, &my_cmd, sizeof(my_cmd))) {
ret = -EFAULT;
break;
}
break;
case RTLTOOL_WRITE_EPHY:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
rtl8168_ephy_write(tp->mmio_addr, my_cmd.offset, my_cmd.data);
break;
case RTLTOOL_READ_PCI:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
my_cmd.data = 0;
if (my_cmd.len==1)
pci_read_config_byte(tp->pci_dev, my_cmd.offset,
//.........这里部分代码省略.........
示例2: calypso_sim_regdump
/* Display Register dump */
void calypso_sim_regdump(void)
{
#ifdef DEBUG
unsigned int regVal;
#define SIM_DEBUG_OUTPUTDELAY 200
puts("\n\n\n");
puts("====================== CALYPSO SIM REGISTER DUMP =====================\n");
puts("Reg_sim_cmd register (R/W) - FFFE:0000\n");
regVal = readw(REG_SIM_CMD);
printf(" |-REG_SIM_CMD = %04x\n", readw(REG_SIM_CMD));
if(regVal & REG_SIM_CMD_CMDCARDRST)
puts(" | |-REG_SIM_CMD_CMDCARDRST = 1 ==> SIM card reset sequence enabled.\n");
else
puts(" | |-REG_SIM_CMD_CMDCARDRST = 0 ==> SIM card reset sequence disabled.\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_CMD_CMDIFRST)
puts(" | |-REG_SIM_CMD_CMDIFRST = 1\n");
else
puts(" | |-REG_SIM_CMD_CMDIFRST = 0\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_CMD_CMDSTOP)
puts(" | |-REG_SIM_CMD_CMDSTOP = 1\n");
else
puts(" | |-REG_SIM_CMD_CMDSTOP = 0\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_CMD_CMDSTART)
puts(" | |-REG_SIM_CMD_CMDSTART = 1 ==> SIM card start procedure active.\n");
else
puts(" | |-REG_SIM_CMD_CMDSTART = 0\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_CMD_CMDSTART)
puts(" | |-REG_SIM_CMD_MODULE_CLK_EN = 1 ==> Clock of the module enabled.\n");
else
puts(" | |-REG_SIM_CMD_MODULE_CLK_EN = 0 ==> Clock of the module disabled.\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
regVal = readw(REG_SIM_STAT);
printf(" |-REG_SIM_STAT = %04x\n", regVal);
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_STAT_STATNOCARD)
puts(" | |-REG_SIM_STAT_STATNOCARD = 1 ==> No card!\n");
else
puts(" | |-REG_SIM_STAT_STATNOCARD = 0 ==> Card detected!\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_STAT_STATTXPAR)
puts(" | |-REG_SIM_STAT_STATTXPAR = 1 ==> Parity ok!\n");
else
puts(" | |-REG_SIM_STAT_STATTXPAR = 0 ==> Parity error!\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_STAT_STATFIFOFULL)
puts(" | |-REG_SIM_STAT_STATFIFOFULL = 1 ==> Fifo full!\n");
else
puts(" | |-REG_SIM_STAT_STATFIFOFULL = 0\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_STAT_STATFIFOEMPTY)
puts(" | |-REG_SIM_STAT_STATFIFOEMPTY = 1 ==> Fifo empty!\n");
else
puts(" | |-REG_SIM_STAT_STATFIFOEMPTY = 0\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
regVal = readw(REG_SIM_CONF1);
printf(" |-REG_SIM_CONF1 = %04x\n", regVal);
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_CONF1_CONFCHKPAR)
puts(" | |-REG_SIM_CONF1_CONFCHKPAR = 1 ==> Parity check on reception enabled.\n");
else
puts(" | |-REG_SIM_CONF1_CONFCHKPAR = 0 ==> Parity check on reception disabled.\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_CONF1_CONFCODCONV)
puts(" | |-REG_SIM_CONF1_CONFCODCONV = 1 ==> Coding convention is inverse.\n");
else
puts(" | |-REG_SIM_CONF1_CONFCODCONV = 0 ==> Coding convention is direct (normal).\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_CONF1_CONFTXRX)
puts(" | |-REG_SIM_CONF1_CONFTXRX = 1 ==> SIO line direction is in transmit mode.\n");
else
puts(" | |-REG_SIM_CONF1_CONFTXRX = 0 ==> SIO line direction is in receive mode.\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
if(regVal & REG_SIM_CONF1_CONFSCLKEN)
puts(" | |-REG_SIM_CONF1_CONFSCLKEN = 1 ==> SIM clock in normal mode.\n");
else
puts(" | |-REG_SIM_CONF1_CONFSCLKEN = 0 ==> SIM clock in standby mode.\n");
delay_ms(SIM_DEBUG_OUTPUTDELAY);
//.........这里部分代码省略.........
示例3: rio_probe1
//.........这里部分代码省略.........
np->vlan = (vlan[card_idx] > 0 && vlan[card_idx] < 4096) ?
vlan[card_idx] : 0;
if (rx_coalesce > 0 && rx_timeout > 0) {
np->rx_coalesce = rx_coalesce;
np->rx_timeout = rx_timeout;
np->coalesce = 1;
}
np->tx_flow = (tx_flow == 0) ? 0 : 1;
np->rx_flow = (rx_flow == 0) ? 0 : 1;
if (tx_coalesce < 1)
tx_coalesce = 1;
else if (tx_coalesce > TX_RING_SIZE-1)
tx_coalesce = TX_RING_SIZE - 1;
}
dev->netdev_ops = &netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
SET_ETHTOOL_OPS(dev, ðtool_ops);
#if 0
dev->features = NETIF_F_IP_CSUM;
#endif
pci_set_drvdata (pdev, dev);
ring_space = pci_alloc_consistent (pdev, TX_TOTAL_SIZE, &ring_dma);
if (!ring_space)
goto err_out_iounmap;
np->tx_ring = (struct netdev_desc *) ring_space;
np->tx_ring_dma = ring_dma;
ring_space = pci_alloc_consistent (pdev, RX_TOTAL_SIZE, &ring_dma);
if (!ring_space)
goto err_out_unmap_tx;
np->rx_ring = (struct netdev_desc *) ring_space;
np->rx_ring_dma = ring_dma;
/* Parse eeprom data */
parse_eeprom (dev);
/* Find PHY address */
err = find_miiphy (dev);
if (err)
goto err_out_unmap_rx;
/* Fiber device? */
np->phy_media = (readw(ioaddr + ASICCtrl) & PhyMedia) ? 1 : 0;
np->link_status = 0;
/* Set media and reset PHY */
if (np->phy_media) {
/* default Auto-Negotiation for fiber deivices */
if (np->an_enable == 2) {
np->an_enable = 1;
}
mii_set_media_pcs (dev);
} else {
/* Auto-Negotiation is mandatory for 1000BASE-T,
IEEE 802.3ab Annex 28D page 14 */
if (np->speed == 1000)
np->an_enable = 1;
mii_set_media (dev);
}
err = register_netdev (dev);
if (err)
goto err_out_unmap_rx;
card_idx++;
printk (KERN_INFO "%s: %s, %pM, IRQ %d\n",
dev->name, np->name, dev->dev_addr, irq);
if (tx_coalesce > 1)
printk(KERN_INFO "tx_coalesce:\t%d packets\n",
tx_coalesce);
if (np->coalesce)
printk(KERN_INFO
"rx_coalesce:\t%d packets\n"
"rx_timeout: \t%d ns\n",
np->rx_coalesce, np->rx_timeout*640);
if (np->vlan)
printk(KERN_INFO "vlan(id):\t%d\n", np->vlan);
return 0;
err_out_unmap_rx:
pci_free_consistent (pdev, RX_TOTAL_SIZE, np->rx_ring, np->rx_ring_dma);
err_out_unmap_tx:
pci_free_consistent (pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma);
err_out_iounmap:
#ifdef MEM_MAPPING
iounmap ((void *) ioaddr);
err_out_dev:
#endif
free_netdev (dev);
err_out_res:
pci_release_regions (pdev);
err_out_disable:
pci_disable_device (pdev);
return err;
}
示例4: load_archive_file
/**
* load_ani() - loads an animation
* @nr: number of the animation
*/
void Cseg027::load_ani(const signed short nr)
{
struct sm_file smf;
unsigned short bytes;
Bit32u off_imdata, off_palette;
Bit16u width, height;
Bit8u compression_type;
Bit8u palette_size;
Bit8u num_elements;
int off_elements;
Bit8u* ptr_elements;
//signed int area_size;
int len;
signed int len_3, len_4;
unsigned int offset, offset_2;
Bit8u *dst, *p6;
int ani_off, ani_len;/*
Bit8u *p5;
signed int p4;
signed int p3;*/
Bit8u *p2;
Bit8u *p1;
Bit32u ani_buffer;
Bit8u *ani_main_ptr;
Bit8u *palette_ptr;
/*
unsigned short ems_handle;
Bit8u *p_area;
unsigned short i;
unsigned short fd;
signed short area_changes;
signed short area_pics;
unsigned short i_area;
signed short di;
/* sanity check */
if (nr == -1)
return;
if (nr > 36)
return;
/* no need to reload the same ani*/
//if (nr == globvars->current_ani)
// return;
//ds_writew(0x29ae, 0);
/* set the new ani nr*/
globvars->current_ani=nr;
/* clear the old ani */
//clear_ani(); seg004
if (!anis_loaded[nr-1]){
/* load ANIS.TAB */
load_archive_file(0x17,&smf);
bytes = read_archive_file(&smf, buffer, 148);
fclose(smf.fd);
ani_off = readd(buffer - 4 + nr * 4);
ani_len = readd(buffer + nr * 4) - ani_off;
/* load ANIS */
load_archive_file(0x16,&smf);//fd = load_archive_file(0x16);
/* seek to ordered ani */
fseek(smf.fd, smf.off + ani_off, SEEK_SET);//seg002_0c72(fd, ani_off);
bytes = read_archive_file(&smf, buffer, (unsigned short)ani_len);//fd, Real2Host(ds_readd(0xc3db)),
fclose(smf.fd);
off_imdata = readd(buffer);//ds_readd(0xc3db);
off_palette = readd(buffer+4);
width = readw(buffer+8);
height = readb(buffer+10);
num_elements = readb(buffer+11);
//für jedes Element:
off_elements = readd(buffer+12);
ptr_elements = buffer + off_elements;
//posx = readw(ptr_elements+4);
//posy = readb(ptr_elements+6);
//width = readb(ptr_elements+7);
//height = readb(ptr_elements+8);
//anz = readb(ptr_elements+11);
//for i<anz
//posx = readb(ptr_elements+12+i*4);
//posy = readb(ptr_elements+12+i*4+1);
//anzanim = readw(ptr_elements+12+anz*4);
//for i<anzanim
//index = readw(ptr_elements+12+anz*4 + 4*i);
//delay = readw(ptr_elements+12+anz*4 + 4*i+2);
//.........这里部分代码省略.........
示例5: imx_keypad_check_for_events
/*
* imx_keypad_check_for_events is the timer handler.
*/
static void imx_keypad_check_for_events(unsigned long data)
{
struct imx_keypad *keypad = (struct imx_keypad *) data;
unsigned short matrix_volatile_state[MAX_MATRIX_KEY_COLS];
unsigned short reg_val;
bool state_changed, is_zero_matrix;
int i;
memset(matrix_volatile_state, 0, sizeof(matrix_volatile_state));
imx_keypad_scan_matrix(keypad, matrix_volatile_state);
state_changed = false;
for (i = 0; i < MAX_MATRIX_KEY_COLS; i++) {
if ((keypad->cols_en_mask & (1 << i)) == 0)
continue;
if (keypad->matrix_unstable_state[i] ^ matrix_volatile_state[i]) {
state_changed = true;
break;
}
}
/*
* If the matrix state is changed from the previous scan
* (Re)Begin the debouncing process, saving the new state in
* keypad->matrix_unstable_state.
* else
* Increase the count of number of scans with a stable state.
*/
if (state_changed) {
memcpy(keypad->matrix_unstable_state, matrix_volatile_state,
sizeof(matrix_volatile_state));
keypad->stable_count = 0;
} else
keypad->stable_count++;
/*
* If the matrix is not as stable as we want reschedule scan
* in the near future.
*/
if (keypad->stable_count < IMX_KEYPAD_SCANS_FOR_STABILITY) {
mod_timer(&keypad->check_matrix_timer,
jiffies + msecs_to_jiffies(10));
return;
}
/*
* If the matrix state is stable, fire the events and save the new
* stable state. Note, if the matrix is kept stable for longer
* (keypad->stable_count > IMX_KEYPAD_SCANS_FOR_STABILITY) all
* events have already been generated.
*/
if (keypad->stable_count == IMX_KEYPAD_SCANS_FOR_STABILITY) {
imx_keypad_fire_events(keypad, matrix_volatile_state);
memcpy(keypad->matrix_stable_state, matrix_volatile_state,
sizeof(matrix_volatile_state));
}
is_zero_matrix = true;
for (i = 0; i < MAX_MATRIX_KEY_COLS; i++) {
if (matrix_volatile_state[i] != 0) {
is_zero_matrix = false;
break;
}
}
if (is_zero_matrix) {
/*
* All keys have been released. Enable only the KDI
* interrupt for future key presses (clear the KDI
* status bit and its sync chain before that).
*/
reg_val = readw(keypad->mmio_base + KPSR);
reg_val |= KBD_STAT_KPKD | KBD_STAT_KDSC;
writew(reg_val, keypad->mmio_base + KPSR);
reg_val = readw(keypad->mmio_base + KPSR);
reg_val |= KBD_STAT_KDIE;
reg_val &= ~KBD_STAT_KRIE;
writew(reg_val, keypad->mmio_base + KPSR);
} else {
/*
* Some keys are still pressed. Schedule a rescan in
* attempt to detect multiple key presses and enable
* the KRI interrupt to react quickly to key release
* event.
*/
mod_timer(&keypad->check_matrix_timer,
jiffies + msecs_to_jiffies(60));
reg_val = readw(keypad->mmio_base + KPSR);
reg_val |= KBD_STAT_KPKR | KBD_STAT_KRSS;
writew(reg_val, keypad->mmio_base + KPSR);
//.........这里部分代码省略.........
示例6: wmt_i2c_read
static int wmt_i2c_read(struct i2c_adapter *adap, struct i2c_msg *pmsg,
int last)
{
struct wmt_i2c_dev *i2c_dev = i2c_get_adapdata(adap);
u16 val, tcr_val;
int ret;
unsigned long wait_result;
u32 xfer_len = 0;
if (!(pmsg->flags & I2C_M_NOSTART)) {
ret = wmt_i2c_wait_bus_not_busy(i2c_dev);
if (ret < 0)
return ret;
}
val = readw(i2c_dev->base + REG_CR);
val &= ~CR_TX_END;
writew(val, i2c_dev->base + REG_CR);
val = readw(i2c_dev->base + REG_CR);
val &= ~CR_TX_NEXT_NO_ACK;
writew(val, i2c_dev->base + REG_CR);
if (!(pmsg->flags & I2C_M_NOSTART)) {
val = readw(i2c_dev->base + REG_CR);
val |= CR_CPU_RDY;
writew(val, i2c_dev->base + REG_CR);
}
if (pmsg->len == 1) {
val = readw(i2c_dev->base + REG_CR);
val |= CR_TX_NEXT_NO_ACK;
writew(val, i2c_dev->base + REG_CR);
}
reinit_completion(&i2c_dev->complete);
if (i2c_dev->mode == I2C_MODE_STANDARD)
tcr_val = TCR_STANDARD_MODE;
else
tcr_val = TCR_FAST_MODE;
tcr_val |= TCR_MASTER_READ | (pmsg->addr & TCR_SLAVE_ADDR_MASK);
writew(tcr_val, i2c_dev->base + REG_TCR);
if (pmsg->flags & I2C_M_NOSTART) {
val = readw(i2c_dev->base + REG_CR);
val |= CR_CPU_RDY;
writew(val, i2c_dev->base + REG_CR);
}
while (xfer_len < pmsg->len) {
wait_result = wait_for_completion_timeout(&i2c_dev->complete,
msecs_to_jiffies(500));
if (!wait_result)
return -ETIMEDOUT;
ret = wmt_check_status(i2c_dev);
if (ret)
return ret;
pmsg->buf[xfer_len] = readw(i2c_dev->base + REG_CDR) >> 8;
xfer_len++;
if (xfer_len == pmsg->len - 1) {
val = readw(i2c_dev->base + REG_CR);
val |= (CR_TX_NEXT_NO_ACK | CR_CPU_RDY);
writew(val, i2c_dev->base + REG_CR);
} else {
val = readw(i2c_dev->base + REG_CR);
val |= CR_CPU_RDY;
writew(val, i2c_dev->base + REG_CR);
}
}
return 0;
}
示例7: ad1889_readw
static inline u16
ad1889_readw(struct snd_ad1889 *chip, unsigned reg)
{
return readw(chip->iobase + reg);
}
示例8: bgpio_read16
static unsigned long bgpio_read16(void __iomem *reg)
{
return readw(reg);
}
示例9: ioread16
unsigned int ioread16(void __iomem *addr)
{
return readw(addr);
}
示例10: NCR5380_pread
static inline int
NCR5380_pread(struct Scsi_Host *host, unsigned char *addr, int len)
{
unsigned long *laddr;
void __iomem *dma = priv(host)->dma + 0x2000;
if(!len) return 0;
writeb(0x00, priv(host)->base + CTRL);
laddr = (unsigned long *)addr;
while(len >= 32)
{
unsigned int status;
status = readb(priv(host)->base + STAT);
if(status & 0x80)
goto end;
if(!(status & 0x40))
continue;
*laddr++ = readw(dma) | (readw(dma) << 16);
*laddr++ = readw(dma) | (readw(dma) << 16);
*laddr++ = readw(dma) | (readw(dma) << 16);
*laddr++ = readw(dma) | (readw(dma) << 16);
*laddr++ = readw(dma) | (readw(dma) << 16);
*laddr++ = readw(dma) | (readw(dma) << 16);
*laddr++ = readw(dma) | (readw(dma) << 16);
*laddr++ = readw(dma) | (readw(dma) << 16);
len -= 32;
if(len == 0)
break;
}
addr = (unsigned char *)laddr;
writeb(0x10, priv(host)->base + CTRL);
while(len > 0)
{
unsigned int status;
status = readb(priv(host)->base + STAT);
if(status & 0x80)
goto end;
if(status & 0x40)
{
*addr++ = readb(dma);
if(--len == 0)
break;
}
status = readb(priv(host)->base + STAT);
if(status & 0x80)
goto end;
if(status & 0x40)
{
*addr++ = readb(dma);
if(--len == 0)
break;
}
}
end:
writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
return len;
}
示例11: apple_bc_enable
void apple_bc_enable(struct usb_hcd *hcd, bool enable, int mode, int *pBackup)
{
if(hcd->bc_base == 0)
{
printk("This IC do not support USB BC funciton (%s)\n", __func__);
return;
}
if (enable) {
if (hcd->bc_apple_enable_flag == false) {
printk("Apple BC enable \n");
//disable init.
if (hcd->ehc_base)
{
*pBackup = readb((void *)(hcd->ehc_base+(0x18*2)));
writeb(readb((void *)(hcd->ehc_base+(0x18*2))) & (~0x3F) , (void *)(hcd->ehc_base+(0x18*2)));
}
else if (hcd->xhci_base)
{
writeb(readb((void *)(hcd->xhci_base+0x2020)) & (~0x2) , (void *)(hcd->xhci_base+0x2020));
}
writeb(readb((void *)(hcd->utmi_base)) | 0x2, (void *)(hcd->utmi_base)); // [1]re_term_override
#if defined(USB_BATTERY_CHARGE_SETTING_1)
writew(readw((void *)(hcd->bc_base+(0x2*2))) | 0x5080, (void *)(hcd->bc_base+(0x2*2))); //[14] reg_host_bc_en=1, [12]reg_bc_debug_mask=1
if (mode == REG_BC_MODE_IPAD)
writeb(readb((void *)(hcd->bc_base+(0x8*2))) | 0x2, (void *)(hcd->bc_base+(0x8*2)));
if (mode == REG_BC_MODE_IPHONE)
writeb(readb((void *)(hcd->bc_base+(0x8*2))) | 0x1, (void *)(hcd->bc_base+(0x8*2)));
#else
writeb(readb((void *)(hcd->bc_base+(0x3*2-1))) | 0x50, (void *)(hcd->bc_base+(0x3*2-1))); //[14] reg_host_bc_en=1, [12]reg_bc_debug_mask=1
#endif
writeb(readb((void *)(hcd->bc_base+(0xc*2))) | 0x40, (void *)(hcd->bc_base+(0xc*2))); // [6]= reg_into_host_bc_sw_tri
writew(0x00FF, (void *)(hcd->bc_base)); // [15:0] = bc_ctl_ov_en
writeb(readb((void *)(hcd->bc_base+(0xe*2))) | (mode|0x1), (void *)(hcd->bc_base+(0xe*2))); //[0]reg_apple_bc_en=1, [1:2]=2b'10,ipad mode, [1:2]=2b'01,iphone mode
hcd->bc_apple_enable_flag = true;
}
}
else {
if (hcd->bc_apple_enable_flag == true) {
printk("Apple BC disable \n");
writeb(readb((void *)(hcd->utmi_base)) & (~0x2), (void *)(hcd->utmi_base)); // [1]re_term_override
writew(0x0000, (void *)(hcd->bc_base)); // [15:0] = bc_ctl_ov_en
writeb(readb((void *)(hcd->bc_base+(0xc*2))) & (~0x40), (void *)(hcd->bc_base+(0xc*2))); // [6]= reg_into_host_bc_sw_tri
#if defined(USB_BATTERY_CHARGE_SETTING_1)
writew(readw((void *)(hcd->bc_base+(0x2*2))) & (~0x5080), (void *)(hcd->bc_base+(0x2*2))); //[14] reg_host_bc_en=1, [12]reg_bc_debug_mask=1
if (mode == REG_BC_MODE_IPAD)
writeb(readb((void *)(hcd->bc_base+(0x8*2))) & (~0x2), (void *)(hcd->bc_base+(0x8*2)));
if (mode == REG_BC_MODE_IPHONE)
writeb(readb((void *)(hcd->bc_base+(0x8*2))) & (~0x1), (void *)(hcd->bc_base+(0x8*2)));
#else
writeb(readb((void *)(hcd->bc_base+(0x3*2-1))) & (~0x50), (void *)(hcd->bc_base+(0x3*2-1))); // [6]= reg_host_bc_en
#endif
writeb(readb((void *)(hcd->bc_base+(0xe*2))) & (~0x1), (void *)(hcd->bc_base+(0xe*2))); //[0]reg_apple_bc_en=1
/// hcd->bc_apple_enable_flag = false; //disable it later.
//enable init.
if (hcd->ehc_base)
{
writeb(readb((void *)(hcd->ehc_base+(0x18*2))) | (*pBackup) , (void *)(hcd->ehc_base+(0x18*2)));
}
else if (hcd->xhci_base)
{
writeb(readb((void *)(hcd->xhci_base+0x2020)) | 0x2 , (void *)(hcd->xhci_base+0x2020));
}
hcd->bc_apple_enable_flag = false;
}
}
}
示例12: read_reg
static inline unsigned short read_reg(struct omap2_onenand *c, int reg)
{
return readw(c->onenand.base + reg);
}
示例13: zasevb_modinit
/*!
* zasevb_modinit() - linux module initialization
*
* This needs to initialize the hcd, pcd and tcd drivers. This includes tcd and possibly hcd
* for some architectures.
*
*/
static int zasevb_modinit (void)
{
struct otg_instance *otg = NULL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
struct clk *clk = clk_get(NULL, "usb_clk");
clk_enable(clk);
clk_put(clk);
#endif
THROW_UNLESS((otg = otg_create()), error);
mxc_pcd_ops_init();
#if !defined(OTG_C99)
pcd_global_init();
fs_ocd_global_init();
zasevb_tcd_global_init();
fs_pcd_global_init();
#endif /* !defined(OTG_C99) */
ZAS = otg_trace_obtain_tag(otg, "zas");
mxc_procfs_init();
TRACE_MSG0(ZAS, "1. ZAS");
#if 0
/* ZAS EVB Platform setup
*/
TRACE_MSG4(ZAS, "BCTRL Version: %04x Status: %04x 1: %04x 2: %04x",
readw(PBC_BASE_ADDRESS ),
readw(PBC_BASE_ADDRESS + PBC_BSTAT),
readw(PBC_BASE_ADDRESS + PBC_BCTRL1_SET),
readw(PBC_BASE_ADDRESS + PBC_BCTRL2_SET));
#endif
/* ZAS EVB Clock setup
*/
#if defined(CONFIG_ARCH_ARGONPLUS) || defined(CONFIG_ARCH_ARGONLV)
#define ZASEVB_MULTIPLIER 12
#define ZASEVB_DIVISOR 775 // ~10.
#else
#define ZASEVB_MULTIPLIER 12
#define ZASEVB_DIVISOR 155
#endif
TRACE_MSG0(ZAS, "2. Setup GPT");
THROW_UNLESS(ocd_instance = otg_set_ocd_ops(otg, &ocd_ops), error);
REMOVE_OCD = ocd_instance->TAG;
// XXX THROW_IF((ocd_ops.mod_init ? ocd_ops.mod_init() : 0), error);
#if defined(CONFIG_OTG_GPTR)
mxc_gptcr_mod_init(ZASEVB_DIVISOR, ZASEVB_MULTIPLIER);
#endif /* defined(CONFIG_OTG_GPTR) */
#if defined(CONFIG_OTG_HRT)
mxc_hrt_mod_init(otg, ZASEVB_DIVISOR, ZASEVB_MULTIPLIER);
#endif /* defined(CONFIG_OTG_GPTR) */
#if !defined(CONFIG_USB_HOST)
TRACE_MSG0(ZAS, "3. PCD");
THROW_UNLESS(REMOVE_pcd_instance = otg_set_pcd_ops(otg, &pcd_ops), error);
REMOVE_PCD = REMOVE_pcd_instance->TAG;
// XXX THROW_IF((pcd_ops.mod_init ? pcd_ops.mod_init() : 0), error);
#else /* !defined(CONFIG_USB_HOST) */
printk(KERN_INFO"%s: PCD DRIVER N/A\n", __FUNCTION__);
#endif /* !defined(CONFIG_USB_HOST) */
TRACE_MSG0(ZAS, "4. TCD");
THROW_UNLESS(REMOVE_tcd_instance = otg_set_tcd_ops(otg, &tcd_ops), error);
REMOVE_TCD = REMOVE_tcd_instance->TAG;
// XXX THROW_IF((tcd_ops.mod_init ? tcd_ops.mod_init() : 0), error);
#ifdef OTG_USE_I2C
TRACE_MSG0(ZAS, "0. I2C");
i2c_mod_init(otg);
#endif
#if defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE)
TRACE_MSG0(ZAS, "5. Host");
THROW_UNLESS(hcd_instance = otg_set_hcd_ops(otg, &hcd_ops), error);
HCD = hcd_instance->TAG;
// XXX THROW_IF((hcd_ops.mod_init) ? hcd_ops.mod_init() : 0, error);
#else /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */
printk(KERN_INFO"%s: HCD DRIVER N/A\n", __FUNCTION__);
#endif /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */
//.........这里部分代码省略.........
示例14: shpc_readw
static inline u16 shpc_readw(struct controller *ctrl, int reg)
{
return readw(ctrl->creg + reg);
}
示例15: RIOFixPhbs
void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
{
unsigned short link, port;
struct Port *PortP;
unsigned long flags;
int PortN = HostP->Mapping[unit].SysPort;
rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
if (PortN != -1) {
unsigned short dest_unit = HostP->Mapping[unit].ID2;
/*
** Get the link number used for the 1st 8 phbs on this unit.
*/
PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort];
link = readw(&PortP->PhbP->link);
for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
unsigned short dest_port = port + 8;
u16 __iomem *TxPktP;
struct PKT __iomem *Pkt;
PortP = p->RIOPortp[PortN];
rio_spin_lock_irqsave(&PortP->portSem, flags);
/*
** If RTA is not powered on, the tx packets will be
** unset, so go no further.
*/
if (!PortP->TxStart) {
rio_dprintk(RIO_DEBUG_ROUTE, "Tx pkts not set up yet\n");
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
break;
}
/*
** For the second slot of a 16 port RTA, the driver needs to
** sort out the phb to port mappings. The dest_unit for this
** group of 8 phbs is set to the dest_unit of the accompanying
** 8 port block. The dest_port of the second unit is set to
** be in the range 8-15 (i.e. 8 is added). Thus, for a 16 port
** RTA with IDs 5 and 6, traffic bound for port 6 of unit 6
** (being the second map ID) will be sent to dest_unit 5, port
** 14. When this RTA is deleted, dest_unit for ID 6 will be
** restored, and the dest_port will be reduced by 8.
** Transmit packets also have a destination field which needs
** adjusting in the same manner.
** Note that the unit/port bytes in 'dest' are swapped.
** We also need to adjust the phb and rup link numbers for the
** second block of 8 ttys.
*/
for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
/*
** *TxPktP is the pointer to the transmit packet on the host
** card. This needs to be translated into a 32 bit pointer
** so it can be accessed from the driver.
*/
Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(TxPktP));
/*
** If the packet is used, reset it.
*/
Pkt = (struct PKT __iomem *) ((unsigned long) Pkt & ~PKT_IN_USE);
writeb(dest_unit, &Pkt->dest_unit);
writeb(dest_port, &Pkt->dest_port);
}
rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", readw(&PortP->PhbP->destination) & 0xff, (readw(&PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port);
writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
writew(link, &PortP->PhbP->link);
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
}
/*
** Now make sure the range of ports to be serviced includes
** the 2nd 8 on this 16 port RTA.
*/
if (link > 3)
return;
if (((unit * 8) + 7) > readw(&HostP->LinkStrP[link].last_port)) {
rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7);
writew((unit * 8) + 7, &HostP->LinkStrP[link].last_port);
}
}