mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-20 19:41:47 +00:00
Use readl/writel for portable access to PCI memory
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1996 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
0fe25e0317
commit
76c05536bf
3 files changed
+66
-99
No files matched your search
+28
-38
@@ -81,33 +81,23 @@ MODULE_LICENSE("GPL");
|
||||
static void config_i810(struct pci_dev *dev);
|
||||
|
||||
|
||||
static unsigned char *mem;
|
||||
|
||||
static inline void outlong(unsigned int dat, int off)
|
||||
{
|
||||
*((unsigned int *) (mem + off)) = dat;
|
||||
}
|
||||
|
||||
static inline unsigned int readlong(int off)
|
||||
{
|
||||
return *((unsigned int *) (mem + off));
|
||||
}
|
||||
static unsigned long ioaddr;
|
||||
|
||||
/* The i810 GPIO registers have individual masks for each bit
|
||||
so we never have to read before writing. Nice. */
|
||||
|
||||
static void bit_i810i2c_setscl(void *data, int val)
|
||||
{
|
||||
outlong((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
|
||||
I810_GPIOB);
|
||||
readlong(I810_GPIOB); /* flush posted write */
|
||||
writel((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
|
||||
ioaddr + I810_GPIOB);
|
||||
readl(ioaddr + I810_GPIOB); /* flush posted write */
|
||||
}
|
||||
|
||||
static void bit_i810i2c_setsda(void *data, int val)
|
||||
{
|
||||
outlong((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
|
||||
I810_GPIOB);
|
||||
readlong(I810_GPIOB); /* flush posted write */
|
||||
writel((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
|
||||
ioaddr + I810_GPIOB);
|
||||
readl(ioaddr + I810_GPIOB); /* flush posted write */
|
||||
}
|
||||
|
||||
/* The GPIO pins are open drain, so the pins could always remain outputs.
|
||||
@@ -122,44 +112,44 @@ static void bit_i810i2c_setsda(void *data, int val)
|
||||
|
||||
static int bit_i810i2c_getscl(void *data)
|
||||
{
|
||||
outlong(SCL_DIR_MASK, I810_GPIOB);
|
||||
outlong(0, I810_GPIOB);
|
||||
return (0 != (readlong(I810_GPIOB) & SCL_VAL_IN));
|
||||
writel(SCL_DIR_MASK, ioaddr + I810_GPIOB);
|
||||
writel(0, ioaddr + I810_GPIOB);
|
||||
return (0 != (readl(ioaddr + I810_GPIOB) & SCL_VAL_IN));
|
||||
}
|
||||
|
||||
static int bit_i810i2c_getsda(void *data)
|
||||
{
|
||||
outlong(SDA_DIR_MASK, I810_GPIOB);
|
||||
outlong(0, I810_GPIOB);
|
||||
return (0 != (readlong(I810_GPIOB) & SDA_VAL_IN));
|
||||
writel(SDA_DIR_MASK, ioaddr + I810_GPIOB);
|
||||
writel(0, ioaddr + I810_GPIOB);
|
||||
return (0 != (readl(ioaddr + I810_GPIOB) & SDA_VAL_IN));
|
||||
}
|
||||
|
||||
static void bit_i810ddc_setscl(void *data, int val)
|
||||
{
|
||||
outlong((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
|
||||
I810_GPIOA);
|
||||
readlong(I810_GPIOA); /* flush posted write */
|
||||
writel((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
|
||||
ioaddr + I810_GPIOA);
|
||||
readl(ioaddr + I810_GPIOA); /* flush posted write */
|
||||
}
|
||||
|
||||
static void bit_i810ddc_setsda(void *data, int val)
|
||||
{
|
||||
outlong((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
|
||||
I810_GPIOA);
|
||||
readlong(I810_GPIOA); /* flush posted write */
|
||||
writel((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
|
||||
ioaddr + I810_GPIOA);
|
||||
readl(ioaddr + I810_GPIOA); /* flush posted write */
|
||||
}
|
||||
|
||||
static int bit_i810ddc_getscl(void *data)
|
||||
{
|
||||
outlong(SCL_DIR_MASK, I810_GPIOA);
|
||||
outlong(0, I810_GPIOA);
|
||||
return (0 != (readlong(I810_GPIOA) & SCL_VAL_IN));
|
||||
writel(SCL_DIR_MASK, ioaddr + I810_GPIOA);
|
||||
writel(0, ioaddr + I810_GPIOA);
|
||||
return (0 != (readl(ioaddr + I810_GPIOA) & SCL_VAL_IN));
|
||||
}
|
||||
|
||||
static int bit_i810ddc_getsda(void *data)
|
||||
{
|
||||
outlong(SDA_DIR_MASK, I810_GPIOA);
|
||||
outlong(0, I810_GPIOA);
|
||||
return (0 != (readlong(I810_GPIOA) & SDA_VAL_IN));
|
||||
writel(SDA_DIR_MASK, ioaddr + I810_GPIOA);
|
||||
writel(0, ioaddr + I810_GPIOA);
|
||||
return (0 != (readl(ioaddr + I810_GPIOA) & SDA_VAL_IN));
|
||||
}
|
||||
|
||||
|
||||
@@ -172,8 +162,8 @@ void config_i810(struct pci_dev *dev)
|
||||
cadr = dev->resource[1].start;
|
||||
cadr += I810_IOCONTROL_OFFSET;
|
||||
cadr &= PCI_BASE_ADDRESS_MEM_MASK;
|
||||
mem = ioremap_nocache(cadr, 0x1000);
|
||||
if(mem) {
|
||||
ioaddr = (unsigned long)ioremap_nocache(cadr, 0x1000);
|
||||
if(ioaddr) {
|
||||
bit_i810i2c_setscl(NULL, 1);
|
||||
bit_i810i2c_setsda(NULL, 1);
|
||||
bit_i810ddc_setscl(NULL, 1);
|
||||
@@ -308,7 +298,7 @@ static void __exit i2c_i810_exit(void)
|
||||
pci_unregister_driver(&i810_driver);
|
||||
*/
|
||||
i810_remove(NULL);
|
||||
iounmap(mem);
|
||||
iounmap((void *)ioaddr);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR
|
||||
|
||||
+15
-27
@@ -78,19 +78,7 @@
|
||||
|
||||
static void config_s4(struct pci_dev *dev);
|
||||
|
||||
|
||||
|
||||
static unsigned char *mem;
|
||||
|
||||
static inline void outlong(unsigned int dat)
|
||||
{
|
||||
*((unsigned int *) (mem + REG)) = dat;
|
||||
}
|
||||
|
||||
static inline unsigned int readlong(void)
|
||||
{
|
||||
return *((unsigned int *) (mem + REG));
|
||||
}
|
||||
static unsigned long ioaddr;
|
||||
|
||||
/* The sav GPIO registers don't have individual masks for each bit
|
||||
so we always have to read before writing. */
|
||||
@@ -98,25 +86,25 @@ static inline unsigned int readlong(void)
|
||||
static void bit_savi2c_setscl(void *data, int val)
|
||||
{
|
||||
unsigned int r;
|
||||
r = readlong();
|
||||
r = readl(ioaddr + REG);
|
||||
if(val)
|
||||
r |= I2C_SCL_OUT;
|
||||
else
|
||||
r &= ~I2C_SCL_OUT;
|
||||
outlong(r);
|
||||
readlong(); /* flush posted write */
|
||||
writel(r, ioaddr + REG);
|
||||
readl(ioaddr + REG); /* flush posted write */
|
||||
}
|
||||
|
||||
static void bit_savi2c_setsda(void *data, int val)
|
||||
{
|
||||
unsigned int r;
|
||||
r = readlong();
|
||||
r = readl(ioaddr + REG);
|
||||
if(val)
|
||||
r |= I2C_SDA_OUT;
|
||||
else
|
||||
r &= ~I2C_SDA_OUT;
|
||||
outlong(r);
|
||||
readlong(); /* flush posted write */
|
||||
writel(r, ioaddr + REG);
|
||||
readl(ioaddr + REG); /* flush posted write */
|
||||
}
|
||||
|
||||
/* The GPIO pins are open drain, so the pins always remain outputs.
|
||||
@@ -125,12 +113,12 @@ static void bit_savi2c_setsda(void *data, int val)
|
||||
|
||||
static int bit_savi2c_getscl(void *data)
|
||||
{
|
||||
return (0 != (readlong() & I2C_SCL_IN));
|
||||
return (0 != (readl(ioaddr + REG) & I2C_SCL_IN));
|
||||
}
|
||||
|
||||
static int bit_savi2c_getsda(void *data)
|
||||
{
|
||||
return (0 != (readlong() & I2C_SDA_IN));
|
||||
return (0 != (readl(ioaddr + REG) & I2C_SDA_IN));
|
||||
}
|
||||
|
||||
/* Configures the chip */
|
||||
@@ -142,11 +130,11 @@ void config_s4(struct pci_dev *dev)
|
||||
/* map memory */
|
||||
cadr = dev->resource[0].start;
|
||||
cadr &= PCI_BASE_ADDRESS_MEM_MASK;
|
||||
mem = ioremap_nocache(cadr, 0x0080000);
|
||||
if(mem) {
|
||||
// *((unsigned int *) (mem + REG2)) = 0x8160;
|
||||
*((unsigned int *) (mem + REG)) = 0x00000020;
|
||||
printk("i2c-savage4: Using Savage4 at 0x%p\n", mem);
|
||||
ioaddr = (unsigned long)ioremap_nocache(cadr, 0x0080000);
|
||||
if(ioaddr) {
|
||||
// writel(0x8160, ioaddr + REG2);
|
||||
writel(0x00000020, ioaddr + REG);
|
||||
printk("i2c-savage4: Using Savage4 at 0x%lx\n", ioaddr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +218,7 @@ static void __exit i2c_savage4_exit(void)
|
||||
pci_unregister_driver(&savage4_driver);
|
||||
*/
|
||||
savage4_remove(NULL);
|
||||
iounmap(mem);
|
||||
iounmap((void *)ioaddr);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR
|
||||
|
||||
+23
-34
@@ -65,18 +65,7 @@ MODULE_LICENSE("GPL");
|
||||
|
||||
static void config_v3(struct pci_dev *dev);
|
||||
|
||||
|
||||
static unsigned char *mem;
|
||||
|
||||
static inline void outlong(unsigned int dat)
|
||||
{
|
||||
*((unsigned int *) (mem + REG)) = dat;
|
||||
}
|
||||
|
||||
static inline unsigned int readlong(void)
|
||||
{
|
||||
return *((unsigned int *) (mem + REG));
|
||||
}
|
||||
static unsigned long ioaddr;
|
||||
|
||||
/* The voo GPIO registers don't have individual masks for each bit
|
||||
so we always have to read before writing. */
|
||||
@@ -84,25 +73,25 @@ static inline unsigned int readlong(void)
|
||||
static void bit_vooi2c_setscl(void *data, int val)
|
||||
{
|
||||
unsigned int r;
|
||||
r = readlong();
|
||||
r = readl(ioaddr + REG);
|
||||
if(val)
|
||||
r |= I2C_SCL_OUT;
|
||||
else
|
||||
r &= ~I2C_SCL_OUT;
|
||||
outlong(r);
|
||||
readlong(); /* flush posted write */
|
||||
writel(r, ioaddr + REG);
|
||||
readl(ioaddr + REG); /* flush posted write */
|
||||
}
|
||||
|
||||
static void bit_vooi2c_setsda(void *data, int val)
|
||||
{
|
||||
unsigned int r;
|
||||
r = readlong();
|
||||
r = readl(ioaddr + REG);
|
||||
if(val)
|
||||
r |= I2C_SDA_OUT;
|
||||
else
|
||||
r &= ~I2C_SDA_OUT;
|
||||
outlong(r);
|
||||
readlong(); /* flush posted write */
|
||||
writel(r, ioaddr + REG);
|
||||
readl(ioaddr + REG); /* flush posted write */
|
||||
}
|
||||
|
||||
/* The GPIO pins are open drain, so the pins always remain outputs.
|
||||
@@ -111,46 +100,46 @@ static void bit_vooi2c_setsda(void *data, int val)
|
||||
|
||||
static int bit_vooi2c_getscl(void *data)
|
||||
{
|
||||
return (0 != (readlong() & I2C_SCL_IN));
|
||||
return (0 != (readl(ioaddr + REG) & I2C_SCL_IN));
|
||||
}
|
||||
|
||||
static int bit_vooi2c_getsda(void *data)
|
||||
{
|
||||
return (0 != (readlong() & I2C_SDA_IN));
|
||||
return (0 != (readl(ioaddr + REG) & I2C_SDA_IN));
|
||||
}
|
||||
|
||||
static void bit_vooddc_setscl(void *data, int val)
|
||||
{
|
||||
unsigned int r;
|
||||
r = readlong();
|
||||
r = readl(ioaddr + REG);
|
||||
if(val)
|
||||
r |= DDC_SCL_OUT;
|
||||
else
|
||||
r &= ~DDC_SCL_OUT;
|
||||
outlong(r);
|
||||
readlong(); /* flush posted write */
|
||||
writel(r, ioaddr + REG);
|
||||
readl(ioaddr + REG); /* flush posted write */
|
||||
}
|
||||
|
||||
static void bit_vooddc_setsda(void *data, int val)
|
||||
{
|
||||
unsigned int r;
|
||||
r = readlong();
|
||||
r = readl(ioaddr + REG);
|
||||
if(val)
|
||||
r |= DDC_SDA_OUT;
|
||||
else
|
||||
r &= ~DDC_SDA_OUT;
|
||||
outlong(r);
|
||||
readlong(); /* flush posted write */
|
||||
writel(r, ioaddr + REG);
|
||||
readl(ioaddr + REG); /* flush posted write */
|
||||
}
|
||||
|
||||
static int bit_vooddc_getscl(void *data)
|
||||
{
|
||||
return (0 != (readlong() & DDC_SCL_IN));
|
||||
return (0 != (readl(ioaddr + REG) & DDC_SCL_IN));
|
||||
}
|
||||
|
||||
static int bit_vooddc_getsda(void *data)
|
||||
{
|
||||
return (0 != (readlong() & DDC_SDA_IN));
|
||||
return (0 != (readl(ioaddr + REG) & DDC_SDA_IN));
|
||||
}
|
||||
|
||||
|
||||
@@ -163,11 +152,11 @@ void config_v3(struct pci_dev *dev)
|
||||
/* map Voodoo3 memory */
|
||||
cadr = dev->resource[0].start;
|
||||
cadr &= PCI_BASE_ADDRESS_MEM_MASK;
|
||||
mem = ioremap_nocache(cadr, 0x1000);
|
||||
if(mem) {
|
||||
*((unsigned int *) (mem + REG2)) = 0x8160;
|
||||
*((unsigned int *) (mem + REG)) = 0xcffc0020;
|
||||
printk("i2c-voodoo3: Using Banshee/Voodoo3 at 0x%p\n", mem);
|
||||
ioaddr = (unsigned long)ioremap_nocache(cadr, 0x1000);
|
||||
if(ioaddr) {
|
||||
writel(0x8160, ioaddr + REG2);
|
||||
writel(0xcffc0020, ioaddr + REG);
|
||||
printk("i2c-voodoo3: Using Banshee/Voodoo3 at 0x%lx\n", ioaddr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +268,7 @@ static void __exit i2c_voodoo3_exit(void)
|
||||
pci_unregister_driver(&voodoo3_driver);
|
||||
*/
|
||||
voodoo3_remove(NULL);
|
||||
iounmap(mem);
|
||||
iounmap((void *)ioaddr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user