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
Kirill Smelkov
linux
Commits
dbda961b
Commit
dbda961b
authored
Nov 12, 2004
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge
bk://kernel.bkbits.net/gregkh/linux/i2c-2.6
into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents
717abc98
95e475c9
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
48 deletions
+65
-48
Documentation/i2c/dev-interface
Documentation/i2c/dev-interface
+2
-2
drivers/i2c/chips/rtc8564.c
drivers/i2c/chips/rtc8564.c
+3
-0
drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.c
+18
-1
drivers/i2c/i2c-dev.c
drivers/i2c/i2c-dev.c
+1
-1
drivers/i2c/i2c-sensor-detect.c
drivers/i2c/i2c-sensor-detect.c
+1
-1
include/linux/i2c.h
include/linux/i2c.h
+4
-12
sound/ppc/daca.c
sound/ppc/daca.c
+13
-11
sound/ppc/pmac.h
sound/ppc/pmac.h
+0
-2
sound/ppc/tumbler.c
sound/ppc/tumbler.c
+23
-18
No files found.
Documentation/i2c/dev-interface
View file @
dbda961b
...
...
@@ -3,7 +3,7 @@ possible to access all devices on an adapter from userspace, through
the /dev interface. You need to load module i2c-dev for this.
Each registered i2c adapter gets a number, counting from 0. You can
examine /
proc/bus/i2c
to see what number corresponds to which adapter.
examine /
sys/class/i2c-dev/
to see what number corresponds to which adapter.
I2C device files are character device files with major device number 89
and a minor device number corresponding to the number assigned as
explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ...,
...
...
@@ -19,7 +19,7 @@ Yes, I know, you should never include kernel header files, but until glibc
knows about i2c, there is not much choice.
Now, you have to decide which adapter you want to access. You should
inspect /
proc/bus/i2c
to decide this. Adapter numbers are assigned
inspect /
sys/class/i2c-dev/
to decide this. Adapter numbers are assigned
somewhat dynamically, so you can not even assume /dev/i2c-0 is the
first adapter.
...
...
drivers/i2c/chips/rtc8564.c
View file @
dbda961b
...
...
@@ -66,8 +66,11 @@ static unsigned short normal_addr[] = { 0x51, I2C_CLIENT_END };
static
struct
i2c_client_address_data
addr_data
=
{
.
normal_i2c
=
normal_addr
,
.
normal_i2c_range
=
ignore
,
.
probe
=
ignore
,
.
probe_range
=
ignore
,
.
ignore
=
ignore
,
.
ignore_range
=
ignore
,
.
force
=
ignore
,
};
...
...
drivers/i2c/i2c-core.c
View file @
dbda961b
...
...
@@ -760,7 +760,7 @@ int i2c_probe(struct i2c_adapter *adapter,
if
(
addr
==
address_data
->
normal_i2c
[
i
])
{
found
=
1
;
dev_dbg
(
&
adapter
->
dev
,
"found normal i2c entry for adapter %d, "
"addr %02x
"
,
adap_id
,
addr
);
"addr %02x
\n
"
,
adap_id
,
addr
);
}
}
...
...
@@ -1021,6 +1021,22 @@ s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value)
I2C_SMBUS_WORD_DATA
,
&
data
);
}
/* Returns the number of bytes transferred */
s32
i2c_smbus_write_block_data
(
struct
i2c_client
*
client
,
u8
command
,
u8
length
,
u8
*
values
)
{
union
i2c_smbus_data
data
;
int
i
;
if
(
length
>
I2C_SMBUS_BLOCK_MAX
)
length
=
I2C_SMBUS_BLOCK_MAX
;
for
(
i
=
1
;
i
<=
length
;
i
++
)
data
.
block
[
i
]
=
values
[
i
-
1
];
data
.
block
[
0
]
=
length
;
return
i2c_smbus_xfer
(
client
->
adapter
,
client
->
addr
,
client
->
flags
,
I2C_SMBUS_WRITE
,
command
,
I2C_SMBUS_BLOCK_DATA
,
&
data
);
}
/* Returns the number of read bytes */
s32
i2c_smbus_block_process_call
(
struct
i2c_client
*
client
,
u8
command
,
u8
length
,
u8
*
values
)
{
...
...
@@ -1279,6 +1295,7 @@ EXPORT_SYMBOL(i2c_smbus_read_byte_data);
EXPORT_SYMBOL
(
i2c_smbus_write_byte_data
);
EXPORT_SYMBOL
(
i2c_smbus_read_word_data
);
EXPORT_SYMBOL
(
i2c_smbus_write_word_data
);
EXPORT_SYMBOL
(
i2c_smbus_write_block_data
);
EXPORT_SYMBOL
(
i2c_smbus_read_i2c_block_data
);
EXPORT_SYMBOL
(
i2c_get_functionality
);
...
...
drivers/i2c/i2c-dev.c
View file @
dbda961b
...
...
@@ -539,7 +539,7 @@ static int __init i2c_dev_init(void)
out_unreg_chrdev:
unregister_chrdev
(
I2C_MAJOR
,
"i2c"
);
out:
printk
(
KERN_ERR
"%s: Driver Initialisation failed"
,
__FILE__
);
printk
(
KERN_ERR
"%s: Driver Initialisation failed
\n
"
,
__FILE__
);
return
res
;
}
...
...
drivers/i2c/i2c-sensor-detect.c
View file @
dbda961b
...
...
@@ -115,7 +115,7 @@ int i2c_detect(struct i2c_adapter *adapter,
for
(
i
=
0
;
!
found
&&
(
normal_i2c
[
i
]
!=
I2C_CLIENT_END
);
i
+=
1
)
{
if
(
addr
==
normal_i2c
[
i
])
{
found
=
1
;
dev_dbg
(
&
adapter
->
dev
,
"found normal i2c entry for adapter %d, addr %02x"
,
adapter_id
,
addr
);
dev_dbg
(
&
adapter
->
dev
,
"found normal i2c entry for adapter %d, addr %02x
\n
"
,
adapter_id
,
addr
);
}
}
}
...
...
include/linux/i2c.h
View file @
dbda961b
...
...
@@ -88,20 +88,12 @@ extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
extern
s32
i2c_smbus_read_word_data
(
struct
i2c_client
*
client
,
u8
command
);
extern
s32
i2c_smbus_write_word_data
(
struct
i2c_client
*
client
,
u8
command
,
u16
value
);
extern
s32
i2c_smbus_process_call
(
struct
i2c_client
*
client
,
u8
command
,
u16
value
);
/* Returns the number of read bytes */
extern
s32
i2c_smbus_read_block_data
(
struct
i2c_client
*
client
,
u8
command
,
u8
*
values
);
/* Returns the number of bytes transferred */
extern
s32
i2c_smbus_write_block_data
(
struct
i2c_client
*
client
,
u8
command
,
u8
length
,
u8
*
values
);
u8
command
,
u8
length
,
u8
*
values
);
extern
s32
i2c_smbus_read_i2c_block_data
(
struct
i2c_client
*
client
,
u8
command
,
u8
*
values
);
extern
s32
i2c_smbus_write_i2c_block_data
(
struct
i2c_client
*
client
,
u8
command
,
u8
length
,
u8
*
values
);
u8
command
,
u8
*
values
);
/*
* A driver is capable of handling one or more physical devices present on
...
...
sound/ppc/daca.c
View file @
dbda961b
...
...
@@ -56,10 +56,11 @@ static int daca_init_client(pmac_keywest_t *i2c)
unsigned
short
wdata
=
0x00
;
/* SR: no swap, 1bit delay, 32-48kHz */
/* GCFG: power amp inverted, DAC on */
if
(
snd_pmac_keywest_write_byte
(
i2c
,
DACA_REG_SR
,
0x08
)
<
0
||
snd_pmac_keywest_write_byte
(
i2c
,
DACA_REG_GCFG
,
0x05
)
<
0
)
if
(
i2c_smbus_write_byte_data
(
i2c
->
client
,
DACA_REG_SR
,
0x08
)
<
0
||
i2c_smbus_write_byte_data
(
i2c
->
client
,
DACA_REG_GCFG
,
0x05
)
<
0
)
return
-
EINVAL
;
return
snd_pmac_keywest_write
(
i2c
,
DACA_REG_AVOL
,
2
,
(
unsigned
char
*
)
&
wdata
);
return
i2c_smbus_write_block_data
(
i2c
->
client
,
DACA_REG_AVOL
,
2
,
(
unsigned
char
*
)
&
wdata
);
}
/*
...
...
@@ -81,9 +82,10 @@ static int daca_set_volume(pmac_daca_t *mix)
else
data
[
1
]
=
mix
->
right_vol
;
data
[
1
]
|=
mix
->
deemphasis
?
0x40
:
0
;
if
(
snd_pmac_keywest_write
(
&
mix
->
i2c
,
DACA_REG_AVOL
,
2
,
data
)
<
0
)
{
snd_printk
(
"failed to set volume
\n
"
);
return
-
EINVAL
;
if
(
i2c_smbus_write_block_data
(
mix
->
i2c
.
client
,
DACA_REG_AVOL
,
2
,
data
)
<
0
)
{
snd_printk
(
"failed to set volume
\n
"
);
return
-
EINVAL
;
}
return
0
;
}
...
...
@@ -188,8 +190,8 @@ static int daca_put_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol
change
=
mix
->
amp_on
!=
ucontrol
->
value
.
integer
.
value
[
0
];
if
(
change
)
{
mix
->
amp_on
=
ucontrol
->
value
.
integer
.
value
[
0
];
snd_pmac_keywest_write_byte
(
&
mix
->
i2c
,
DACA_REG_GCFG
,
mix
->
amp_on
?
0x05
:
0x04
);
i2c_smbus_write_byte_data
(
mix
->
i2c
.
client
,
DACA_REG_GCFG
,
mix
->
amp_on
?
0x05
:
0x04
);
}
return
change
;
}
...
...
@@ -220,9 +222,9 @@ static snd_kcontrol_new_t daca_mixers[] = {
static
void
daca_resume
(
pmac_t
*
chip
)
{
pmac_daca_t
*
mix
=
chip
->
mixer_data
;
snd_pmac_keywest_write_byte
(
&
mix
->
i2c
,
DACA_REG_SR
,
0x08
);
snd_pmac_keywest_write_byte
(
&
mix
->
i2c
,
DACA_REG_GCFG
,
mix
->
amp_on
?
0x05
:
0x04
);
i2c_smbus_write_byte_data
(
mix
->
i2c
.
client
,
DACA_REG_SR
,
0x08
);
i2c_smbus_write_byte_data
(
mix
->
i2c
.
client
,
DACA_REG_GCFG
,
mix
->
amp_on
?
0x05
:
0x04
);
daca_set_volume
(
mix
);
}
#endif
/* CONFIG_PMAC_PBOOK */
...
...
sound/ppc/pmac.h
View file @
dbda961b
...
...
@@ -199,8 +199,6 @@ typedef struct snd_pmac_keywest {
int
snd_pmac_keywest_init
(
pmac_keywest_t
*
i2c
);
void
snd_pmac_keywest_cleanup
(
pmac_keywest_t
*
i2c
);
#define snd_pmac_keywest_write(i2c,cmd,len,data) i2c_smbus_write_block_data((i2c)->client, cmd, len, data)
#define snd_pmac_keywest_write_byte(i2c,cmd,data) i2c_smbus_write_byte_data((i2c)->client, cmd, data)
/* misc */
int
snd_pmac_boolean_stereo_info
(
snd_kcontrol_t
*
kcontrol
,
snd_ctl_elem_info_t
*
uinfo
);
...
...
sound/ppc/tumbler.c
View file @
dbda961b
...
...
@@ -109,7 +109,8 @@ static int send_init_client(pmac_keywest_t *i2c, unsigned int *regs)
while
(
*
regs
>
0
)
{
int
err
,
count
=
10
;
do
{
err
=
snd_pmac_keywest_write_byte
(
i2c
,
regs
[
0
],
regs
[
1
]);
err
=
i2c_smbus_write_byte_data
(
i2c
->
client
,
regs
[
0
],
regs
[
1
]);
if
(
err
>=
0
)
break
;
mdelay
(
10
);
...
...
@@ -220,9 +221,10 @@ static int tumbler_set_master_volume(pmac_tumbler_t *mix)
block
[
4
]
=
(
right_vol
>>
8
)
&
0xff
;
block
[
5
]
=
(
right_vol
>>
0
)
&
0xff
;
if
(
snd_pmac_keywest_write
(
&
mix
->
i2c
,
TAS_REG_VOL
,
6
,
block
)
<
0
)
{
snd_printk
(
"failed to set volume
\n
"
);
return
-
EINVAL
;
if
(
i2c_smbus_write_block_data
(
mix
->
i2c
.
client
,
TAS_REG_VOL
,
6
,
block
)
<
0
)
{
snd_printk
(
"failed to set volume
\n
"
);
return
-
EINVAL
;
}
return
0
;
}
...
...
@@ -320,9 +322,10 @@ static int tumbler_set_drc(pmac_tumbler_t *mix)
val
[
1
]
=
0
;
}
if
(
snd_pmac_keywest_write
(
&
mix
->
i2c
,
TAS_REG_DRC
,
2
,
val
)
<
0
)
{
snd_printk
(
"failed to set DRC
\n
"
);
return
-
EINVAL
;
if
(
i2c_smbus_write_block_data
(
mix
->
i2c
.
client
,
TAS_REG_DRC
,
2
,
val
)
<
0
)
{
snd_printk
(
"failed to set DRC
\n
"
);
return
-
EINVAL
;
}
return
0
;
}
...
...
@@ -355,9 +358,10 @@ static int snapper_set_drc(pmac_tumbler_t *mix)
val
[
4
]
=
0x60
;
val
[
5
]
=
0xa0
;
if
(
snd_pmac_keywest_write
(
&
mix
->
i2c
,
TAS_REG_DRC
,
6
,
val
)
<
0
)
{
snd_printk
(
"failed to set DRC
\n
"
);
return
-
EINVAL
;
if
(
i2c_smbus_write_block_data
(
mix
->
i2c
.
client
,
TAS_REG_DRC
,
6
,
val
)
<
0
)
{
snd_printk
(
"failed to set DRC
\n
"
);
return
-
EINVAL
;
}
return
0
;
}
...
...
@@ -459,9 +463,10 @@ static int tumbler_set_mono_volume(pmac_tumbler_t *mix, struct tumbler_mono_vol
vol
=
info
->
table
[
vol
];
for
(
i
=
0
;
i
<
info
->
bytes
;
i
++
)
block
[
i
]
=
(
vol
>>
((
info
->
bytes
-
i
-
1
)
*
8
))
&
0xff
;
if
(
snd_pmac_keywest_write
(
&
mix
->
i2c
,
info
->
reg
,
info
->
bytes
,
block
)
<
0
)
{
snd_printk
(
"failed to set mono volume %d
\n
"
,
info
->
index
);
return
-
EINVAL
;
if
(
i2c_smbus_write_block_data
(
mix
->
i2c
.
client
,
info
->
reg
,
info
->
bytes
,
block
)
<
0
)
{
snd_printk
(
"failed to set mono volume %d
\n
"
,
info
->
index
);
return
-
EINVAL
;
}
return
0
;
}
...
...
@@ -588,9 +593,9 @@ static int snapper_set_mix_vol1(pmac_tumbler_t *mix, int idx, int ch, int reg)
for
(
j
=
0
;
j
<
3
;
j
++
)
block
[
i
*
3
+
j
]
=
(
vol
>>
((
2
-
j
)
*
8
))
&
0xff
;
}
if
(
snd_pmac_keywest_write
(
&
mix
->
i2c
,
reg
,
9
,
block
)
<
0
)
{
snd_printk
(
"failed to set mono volume %d
\n
"
,
reg
);
return
-
EINVAL
;
if
(
i2c_smbus_write_block_data
(
mix
->
i2c
.
client
,
reg
,
9
,
block
)
<
0
)
{
snd_printk
(
"failed to set mono volume %d
\n
"
,
reg
);
return
-
EINVAL
;
}
return
0
;
}
...
...
@@ -689,8 +694,8 @@ static int snapper_set_capture_source(pmac_tumbler_t *mix)
{
if
(
!
mix
->
i2c
.
client
)
return
-
ENODEV
;
return
snd_pmac_keywest_write_byte
(
&
mix
->
i2c
,
TAS_REG_ACS
,
mix
->
capture_source
?
2
:
0
);
return
i2c_smbus_write_byte_data
(
mix
->
i2c
.
client
,
TAS_REG_ACS
,
mix
->
capture_source
?
2
:
0
);
}
static
int
snapper_info_capture_source
(
snd_kcontrol_t
*
kcontrol
,
snd_ctl_elem_info_t
*
uinfo
)
...
...
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