Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
a4639e9d
Commit
a4639e9d
authored
Mar 19, 2003
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] i2c i2c-amd756.c: remove some #ifdefs and fix all printk() to use dev_*().
Also some minor whitespace cleanups.
parent
09a3943b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
70 deletions
+68
-70
drivers/i2c/busses/i2c-amd756.c
drivers/i2c/busses/i2c-amd756.c
+68
-70
No files found.
drivers/i2c/busses/i2c-amd756.c
View file @
a4639e9d
...
@@ -35,6 +35,8 @@
...
@@ -35,6 +35,8 @@
Note: we assume there can only be one device, with one SMBus interface.
Note: we assume there can only be one device, with one SMBus interface.
*/
*/
/* #define DEBUG 1 */
#include <linux/version.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/pci.h>
...
@@ -46,44 +48,42 @@
...
@@ -46,44 +48,42 @@
#include <linux/init.h>
#include <linux/init.h>
#include <asm/io.h>
#include <asm/io.h>
#define DRV_NAME "i2c-amd756"
/* AMD756 SMBus address offsets */
/* AMD756 SMBus address offsets */
#define SMB_ADDR_OFFSET
0xE0
#define SMB_ADDR_OFFSET
0xE0
#define SMB_IOSIZE
16
#define SMB_IOSIZE
16
#define SMB_GLOBAL_STATUS
(0x0 + amd756_ioport)
#define SMB_GLOBAL_STATUS
(0x0 + amd756_ioport)
#define SMB_GLOBAL_ENABLE
(0x2 + amd756_ioport)
#define SMB_GLOBAL_ENABLE
(0x2 + amd756_ioport)
#define SMB_HOST_ADDRESS
(0x4 + amd756_ioport)
#define SMB_HOST_ADDRESS
(0x4 + amd756_ioport)
#define SMB_HOST_DATA
(0x6 + amd756_ioport)
#define SMB_HOST_DATA
(0x6 + amd756_ioport)
#define SMB_HOST_COMMAND
(0x8 + amd756_ioport)
#define SMB_HOST_COMMAND
(0x8 + amd756_ioport)
#define SMB_HOST_BLOCK_DATA
(0x9 + amd756_ioport)
#define SMB_HOST_BLOCK_DATA
(0x9 + amd756_ioport)
#define SMB_HAS_DATA
(0xA + amd756_ioport)
#define SMB_HAS_DATA
(0xA + amd756_ioport)
#define SMB_HAS_DEVICE_ADDRESS
(0xC + amd756_ioport)
#define SMB_HAS_DEVICE_ADDRESS
(0xC + amd756_ioport)
#define SMB_HAS_HOST_ADDRESS
(0xE + amd756_ioport)
#define SMB_HAS_HOST_ADDRESS
(0xE + amd756_ioport)
#define SMB_SNOOP_ADDRESS
(0xF + amd756_ioport)
#define SMB_SNOOP_ADDRESS
(0xF + amd756_ioport)
/* PCI Address Constants */
/* PCI Address Constants */
/* address of I/O space */
/* address of I/O space */
#define SMBBA
0x058
/* mh */
#define SMBBA
0x058
/* mh */
#define SMBBANFORCE
0x014
#define SMBBANFORCE
0x014
/* general configuration */
/* general configuration */
#define SMBGCFG
0x041
/* mh */
#define SMBGCFG
0x041
/* mh */
/* silicon revision code */
/* silicon revision code */
#define SMBREV
0x008
#define SMBREV
0x008
/* Other settings */
/* Other settings */
#define MAX_TIMEOUT
500
#define MAX_TIMEOUT
500
/* AMD756 constants */
/* AMD756 constants */
#define AMD756_QUICK
0x00
#define AMD756_QUICK
0x00
#define AMD756_BYTE
0x01
#define AMD756_BYTE
0x01
#define AMD756_BYTE_DATA
0x02
#define AMD756_BYTE_DATA
0x02
#define AMD756_WORD_DATA
0x03
#define AMD756_WORD_DATA
0x03
#define AMD756_PROCESS_CALL
0x04
#define AMD756_PROCESS_CALL
0x04
#define AMD756_BLOCK_DATA
0x05
#define AMD756_BLOCK_DATA
0x05
static
unsigned
short
amd756_ioport
=
0
;
static
unsigned
short
amd756_ioport
=
0
;
...
@@ -101,36 +101,36 @@ static void amd756_do_pause(unsigned int amount)
...
@@ -101,36 +101,36 @@ static void amd756_do_pause(unsigned int amount)
schedule_timeout
(
amount
);
schedule_timeout
(
amount
);
}
}
#define GS_ABRT_STS
(1 << 0)
#define GS_ABRT_STS
(1 << 0)
#define GS_COL_STS
(1 << 1)
#define GS_COL_STS
(1 << 1)
#define GS_PRERR_STS
(1 << 2)
#define GS_PRERR_STS
(1 << 2)
#define GS_HST_STS
(1 << 3)
#define GS_HST_STS
(1 << 3)
#define GS_HCYC_STS
(1 << 4)
#define GS_HCYC_STS
(1 << 4)
#define GS_TO_STS
(1 << 5)
#define GS_TO_STS
(1 << 5)
#define GS_SMB_STS
(1 << 11)
#define GS_SMB_STS
(1 << 11)
#define GS_CLEAR_STS
(GS_ABRT_STS | GS_COL_STS | GS_PRERR_STS | \
#define GS_CLEAR_STS
(GS_ABRT_STS | GS_COL_STS | GS_PRERR_STS | \
GS_HCYC_STS | GS_TO_STS )
GS_HCYC_STS | GS_TO_STS )
#define GE_CYC_TYPE_MASK
(7)
#define GE_CYC_TYPE_MASK
(7)
#define GE_HOST_STC
(1 << 3)
#define GE_HOST_STC
(1 << 3)
#define GE_ABORT
(1 << 5)
#define GE_ABORT
(1 << 5)
static
int
amd756_transaction
(
void
)
static
int
amd756_transaction
(
struct
i2c_adapter
*
adap
)
{
{
int
temp
;
int
temp
;
int
result
=
0
;
int
result
=
0
;
int
timeout
=
0
;
int
timeout
=
0
;
pr_debug
(
DRV_NAME
dev_dbg
(
&
adap
->
dev
,
": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, "
": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x
\n
"
,
"DAT=%04x
\n
"
,
inw_p
(
SMB_GLOBAL_STATUS
)
,
inw_p
(
SMB_GLOBAL_STATUS
),
inw_p
(
SMB_GLOBAL_ENABLE
),
inw_p
(
SMB_GLOBAL_ENABLE
),
inw_p
(
SMB_HOST_ADDRESS
),
inw_p
(
SMB_HOST_ADDRESS
),
inb_p
(
SMB_HOST_DATA
));
inb_p
(
SMB_HOST_DATA
));
/* Make sure the SMBus host is ready to start transmitting */
/* Make sure the SMBus host is ready to start transmitting */
if
((
temp
=
inw_p
(
SMB_GLOBAL_STATUS
))
&
(
GS_HST_STS
|
GS_SMB_STS
))
{
if
((
temp
=
inw_p
(
SMB_GLOBAL_STATUS
))
&
(
GS_HST_STS
|
GS_SMB_STS
))
{
pr_debug
(
DRV_NAME
": SMBus busy (%04x). Waiting...
\n
"
,
temp
);
dev_dbg
(
&
adap
->
dev
,
": SMBus busy (%04x). Waiting...
\n
"
,
temp
);
do
{
do
{
amd756_do_pause
(
1
);
amd756_do_pause
(
1
);
temp
=
inw_p
(
SMB_GLOBAL_STATUS
);
temp
=
inw_p
(
SMB_GLOBAL_STATUS
);
...
@@ -138,7 +138,7 @@ static int amd756_transaction(void)
...
@@ -138,7 +138,7 @@ static int amd756_transaction(void)
(
timeout
++
<
MAX_TIMEOUT
));
(
timeout
++
<
MAX_TIMEOUT
));
/* If the SMBus is still busy, we give up */
/* If the SMBus is still busy, we give up */
if
(
timeout
>=
MAX_TIMEOUT
)
{
if
(
timeout
>=
MAX_TIMEOUT
)
{
pr_debug
(
DRV_NAME
": Busy wait timeout (%04x)
\n
"
,
temp
);
dev_dbg
(
&
adap
->
dev
,
": Busy wait timeout (%04x)
\n
"
,
temp
);
goto
abort
;
goto
abort
;
}
}
timeout
=
0
;
timeout
=
0
;
...
@@ -155,46 +155,46 @@ static int amd756_transaction(void)
...
@@ -155,46 +155,46 @@ static int amd756_transaction(void)
/* If the SMBus is still busy, we give up */
/* If the SMBus is still busy, we give up */
if
(
timeout
>=
MAX_TIMEOUT
)
{
if
(
timeout
>=
MAX_TIMEOUT
)
{
pr_debug
(
DRV_NAME
": Completion timeout!
\n
"
);
dev_dbg
(
&
adap
->
dev
,
": Completion timeout!
\n
"
);
goto
abort
;
goto
abort
;
}
}
if
(
temp
&
GS_PRERR_STS
)
{
if
(
temp
&
GS_PRERR_STS
)
{
result
=
-
1
;
result
=
-
1
;
pr_debug
(
DRV_NAME
": SMBus Protocol error (no response)!
\n
"
);
dev_dbg
(
&
adap
->
dev
,
": SMBus Protocol error (no response)!
\n
"
);
}
}
if
(
temp
&
GS_COL_STS
)
{
if
(
temp
&
GS_COL_STS
)
{
result
=
-
1
;
result
=
-
1
;
printk
(
KERN_WARNING
DRV_NAME
" SMBus collision!
\n
"
);
dev_warn
(
&
adap
->
dev
,
" SMBus collision!
\n
"
);
}
}
if
(
temp
&
GS_TO_STS
)
{
if
(
temp
&
GS_TO_STS
)
{
result
=
-
1
;
result
=
-
1
;
pr_debug
(
DRV_NAME
": SMBus protocol timeout!
\n
"
);
dev_dbg
(
&
adap
->
dev
,
": SMBus protocol timeout!
\n
"
);
}
}
if
(
temp
&
GS_HCYC_STS
)
if
(
temp
&
GS_HCYC_STS
)
pr_debug
(
DRV_NAME
" SMBus protocol success!
\n
"
);
dev_dbg
(
&
adap
->
dev
,
" SMBus protocol success!
\n
"
);
outw_p
(
GS_CLEAR_STS
,
SMB_GLOBAL_STATUS
);
outw_p
(
GS_CLEAR_STS
,
SMB_GLOBAL_STATUS
);
#ifdef DEBUG
#ifdef DEBUG
if
(((
temp
=
inw_p
(
SMB_GLOBAL_STATUS
))
&
GS_CLEAR_STS
)
!=
0x00
)
{
if
(((
temp
=
inw_p
(
SMB_GLOBAL_STATUS
))
&
GS_CLEAR_STS
)
!=
0x00
)
{
pr_debug
(
DRV_NAME
dev_dbg
(
&
adap
->
dev
,
": Failed reset at end of transaction (%04x)
\n
"
,
temp
);
": Failed reset at end of transaction (%04x)
\n
"
,
temp
);
}
}
pr_debug
(
DRV_NAME
": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x
\n
"
,
inw_p
(
SMB_GLOBAL_STATUS
),
inw_p
(
SMB_GLOBAL_ENABLE
),
inw_p
(
SMB_HOST_ADDRESS
),
inb_p
(
SMB_HOST_DATA
));
#endif
#endif
dev_dbg
(
&
adap
->
dev
,
": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x
\n
"
,
inw_p
(
SMB_GLOBAL_STATUS
),
inw_p
(
SMB_GLOBAL_ENABLE
),
inw_p
(
SMB_HOST_ADDRESS
),
inb_p
(
SMB_HOST_DATA
));
return
result
;
return
result
;
abort:
abort:
printk
(
KERN_WARNING
DRV_NAME
": Sending abort.
\n
"
);
dev_warn
(
&
adap
->
dev
,
": Sending abort.
\n
"
);
outw_p
(
inw
(
SMB_GLOBAL_ENABLE
)
|
GE_ABORT
,
SMB_GLOBAL_ENABLE
);
outw_p
(
inw
(
SMB_GLOBAL_ENABLE
)
|
GE_ABORT
,
SMB_GLOBAL_ENABLE
);
amd756_do_pause
(
100
);
amd756_do_pause
(
100
);
outw_p
(
GS_CLEAR_STS
,
SMB_GLOBAL_STATUS
);
outw_p
(
GS_CLEAR_STS
,
SMB_GLOBAL_STATUS
);
...
@@ -211,7 +211,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
...
@@ -211,7 +211,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
/** TODO: Should I supporte the 10-bit transfers? */
/** TODO: Should I supporte the 10-bit transfers? */
switch
(
size
)
{
switch
(
size
)
{
case
I2C_SMBUS_PROC_CALL
:
case
I2C_SMBUS_PROC_CALL
:
pr_debug
(
DRV_NAME
": I2C_SMBUS_PROC_CALL not supported!
\n
"
);
dev_dbg
(
&
adap
->
dev
,
": I2C_SMBUS_PROC_CALL not supported!
\n
"
);
/* TODO: Well... It is supported, I'm just not sure what to do here... */
/* TODO: Well... It is supported, I'm just not sure what to do here... */
return
-
1
;
return
-
1
;
case
I2C_SMBUS_QUICK
:
case
I2C_SMBUS_QUICK
:
...
@@ -266,7 +266,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
...
@@ -266,7 +266,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
/* How about enabling interrupts... */
/* How about enabling interrupts... */
outw_p
(
size
&
GE_CYC_TYPE_MASK
,
SMB_GLOBAL_ENABLE
);
outw_p
(
size
&
GE_CYC_TYPE_MASK
,
SMB_GLOBAL_ENABLE
);
if
(
amd756_transaction
())
/* Error in transaction */
if
(
amd756_transaction
(
adap
))
/* Error in transaction */
return
-
1
;
return
-
1
;
if
((
read_write
==
I2C_SMBUS_WRITE
)
||
(
size
==
AMD756_QUICK
))
if
((
read_write
==
I2C_SMBUS_WRITE
)
||
(
size
==
AMD756_QUICK
))
...
@@ -334,7 +334,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
...
@@ -334,7 +334,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
u8
temp
;
u8
temp
;
if
(
amd756_ioport
)
{
if
(
amd756_ioport
)
{
printk
(
KERN_ERR
DRV_NAME
": Only one device supported. "
dev_err
(
&
pdev
->
dev
,
": Only one device supported. "
"(you have a strange motherboard, btw..)
\n
"
);
"(you have a strange motherboard, btw..)
\n
"
);
return
-
ENODEV
;
return
-
ENODEV
;
}
}
...
@@ -351,8 +351,8 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
...
@@ -351,8 +351,8 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
pci_read_config_byte
(
pdev
,
SMBGCFG
,
&
temp
);
pci_read_config_byte
(
pdev
,
SMBGCFG
,
&
temp
);
if
((
temp
&
128
)
==
0
)
{
if
((
temp
&
128
)
==
0
)
{
printk
(
KERN_ERR
DRV_NAME
dev_err
(
&
pdev
->
dev
,
": Error: SMBus controller I/O not enabled!
\n
"
);
": Error: SMBus controller I/O not enabled!
\n
"
);
return
-
ENODEV
;
return
-
ENODEV
;
}
}
...
@@ -364,16 +364,14 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
...
@@ -364,16 +364,14 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
}
}
if
(
!
request_region
(
amd756_ioport
,
SMB_IOSIZE
,
"amd756-smbus"
))
{
if
(
!
request_region
(
amd756_ioport
,
SMB_IOSIZE
,
"amd756-smbus"
))
{
printk
(
KERN_ERR
DRV_NAME
dev_err
(
&
pdev
->
dev
,
": SMB region 0x%x already in use!
\n
"
,
": SMB region 0x%x already in use!
\n
"
,
amd756_ioport
);
amd756_ioport
);
return
-
ENODEV
;
return
-
ENODEV
;
}
}
#ifdef DEBUG
pci_read_config_byte
(
pdev
,
SMBREV
,
&
temp
);
pci_read_config_byte
(
pdev
,
SMBREV
,
&
temp
);
printk
(
KERN_DEBUG
DRV_NAME
": SMBREV = 0x%X
\n
"
,
temp
);
dev_dbg
(
&
pdev
->
dev
,
": SMBREV = 0x%X
\n
"
,
temp
);
printk
(
KERN_DEBUG
DRV_NAME
": AMD756_smba = 0x%X
\n
"
,
amd756_ioport
);
dev_dbg
(
&
pdev
->
dev
,
": AMD756_smba = 0x%X
\n
"
,
amd756_ioport
);
#endif
/* set up the driverfs linkage to our parent device */
/* set up the driverfs linkage to our parent device */
amd756_adapter
.
dev
.
parent
=
&
pdev
->
dev
;
amd756_adapter
.
dev
.
parent
=
&
pdev
->
dev
;
...
@@ -383,8 +381,8 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
...
@@ -383,8 +381,8 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
error
=
i2c_add_adapter
(
&
amd756_adapter
);
error
=
i2c_add_adapter
(
&
amd756_adapter
);
if
(
error
)
{
if
(
error
)
{
printk
(
KERN_ERR
DRV_NAME
dev_err
(
&
pdev
->
dev
,
": Adapter registration failed, module not inserted.
\n
"
);
": Adapter registration failed, module not inserted.
\n
"
);
goto
out_err
;
goto
out_err
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment