Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OS
U-Boot.Mirror
提交
cc0427d2
U
U-Boot.Mirror
项目概览
OS
/
U-Boot.Mirror
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
U-Boot.Mirror
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cc0427d2
编写于
8月 26, 2017
作者:
T
Tom Rini
浏览文件
操作
浏览文件
下载
差异文件
Merge
git://git.denx.de/u-boot-i2c
上级
c2150e4d
a430556e
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
1081 addition
and
0 deletion
+1081
-0
doc/device-tree-bindings/i2c/i2c-stm32.txt
doc/device-tree-bindings/i2c/i2c-stm32.txt
+30
-0
drivers/i2c/Kconfig
drivers/i2c/Kconfig
+20
-0
drivers/i2c/Makefile
drivers/i2c/Makefile
+1
-0
drivers/i2c/muxes/Kconfig
drivers/i2c/muxes/Kconfig
+9
-0
drivers/i2c/muxes/Makefile
drivers/i2c/muxes/Makefile
+1
-0
drivers/i2c/muxes/i2c-mux-gpio.c
drivers/i2c/muxes/i2c-mux-gpio.c
+138
-0
drivers/i2c/stm32f7_i2c.c
drivers/i2c/stm32f7_i2c.c
+882
-0
未找到文件。
doc/device-tree-bindings/i2c/i2c-stm32.txt
0 → 100644
浏览文件 @
cc0427d2
* I2C controller embedded in STMicroelectronis STM32 platforms
Required properties :
- compatible : Must be "st,stm32f7-i2c"
- reg : Offset and length of the register set for the device
- resets: Must contain the phandle to the reset controller
- clocks: Must contain the input clock of the I2C instance
- A pinctrl state named "default" must be defined to set pins in mode of
operation for I2C transfer
- #address-cells = <1>;
- #size-cells = <0>;
Optional properties :
- clock-frequency : Desired I2C bus clock frequency in Hz. If not specified,
the default 100 kHz frequency will be used. As only Normal, Fast and Fast+
modes are implemented, possible values are 100000, 400000 and 1000000.
Example :
i2c1: i2c@40005400 {
compatible = "st,stm32f7-i2c";
reg = <0x40005400 0x400>;
resets = <&rcc 181>;
clocks = <&clk_pclk1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
clock-frequency = <400000>;
#address-cells = <1>;
#size-cells = <0>;
};
drivers/i2c/Kconfig
浏览文件 @
cc0427d2
...
...
@@ -174,6 +174,26 @@ config SYS_I2C_S3C24X0
help
Support for Samsung I2C controller as Samsung SoCs.
config SYS_I2C_STM32F7
bool "STMicroelectronics STM32F7 I2C support"
depends on (STM32F7 || STM32H7) && DM_I2C
help
Enable this option to add support for STM32 I2C controller
introduced with STM32F7/H7 SoCs. This I2C controller supports :
_ Slave and master modes
_ Multimaster capability
_ Standard-mode (up to 100 kHz)
_ Fast-mode (up to 400 kHz)
_ Fast-mode Plus (up to 1 MHz)
_ 7-bit and 10-bit addressing mode
_ Multiple 7-bit slave addresses (2 addresses, 1 with configurable mask)
_ All 7-bit addresses acknowledge mode
_ General call
_ Programmable setup and hold times
_ Easy to use event management
_ Optional clock stretching
_ Software reset
config SYS_I2C_UNIPHIER
bool "UniPhier I2C driver"
depends on ARCH_UNIPHIER && DM_I2C
...
...
drivers/i2c/Makefile
浏览文件 @
cc0427d2
...
...
@@ -37,6 +37,7 @@ obj-$(CONFIG_SYS_I2C_S3C24X0) += s3c24x0_i2c.o exynos_hs_i2c.o
obj-$(CONFIG_SYS_I2C_SANDBOX)
+=
sandbox_i2c.o i2c-emul-uclass.o
obj-$(CONFIG_SYS_I2C_SH)
+=
sh_i2c.o
obj-$(CONFIG_SYS_I2C_SOFT)
+=
soft_i2c.o
obj-$(CONFIG_SYS_I2C_STM32F7)
+=
stm32f7_i2c.o
obj-$(CONFIG_SYS_I2C_TEGRA)
+=
tegra_i2c.o
obj-$(CONFIG_SYS_I2C_UNIPHIER)
+=
i2c-uniphier.o
obj-$(CONFIG_SYS_I2C_UNIPHIER_F)
+=
i2c-uniphier-f.o
...
...
drivers/i2c/muxes/Kconfig
浏览文件 @
cc0427d2
...
...
@@ -34,3 +34,12 @@ config I2C_MUX_PCA954x
paritioning I2C bus and connect multiple devices with the same address
to the same I2C controller where driver handles proper routing to
target i2c device. PCA9544 and PCA9548 are supported.
config I2C_MUX_GPIO
tristate "GPIO-based I2C multiplexer"
depends on I2C_MUX && DM_GPIO
help
If you say yes to this option, support will be included for
a GPIO based I2C multiplexer. This driver provides access to
I2C busses connected through a MUX, which is controlled
through GPIO pins.
drivers/i2c/muxes/Makefile
浏览文件 @
cc0427d2
...
...
@@ -6,3 +6,4 @@
obj-$(CONFIG_I2C_ARB_GPIO_CHALLENGE)
+=
i2c-arb-gpio-challenge.o
obj-$(CONFIG_$(SPL_)I2C_MUX)
+=
i2c-mux-uclass.o
obj-$(CONFIG_I2C_MUX_PCA954x)
+=
pca954x.o
obj-$(CONFIG_I2C_MUX_GPIO)
+=
i2c-mux-gpio.o
drivers/i2c/muxes/i2c-mux-gpio.c
0 → 100644
浏览文件 @
cc0427d2
/*
* I2C multiplexer using GPIO API
*
* Copyright 2017 NXP
*
* Peng Fan <peng.fan@nxp.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <asm/io.h>
#include <asm-generic/gpio.h>
#include <common.h>
#include <dm.h>
#include <dm/pinctrl.h>
#include <fdtdec.h>
#include <i2c.h>
#include <linux/errno.h>
DECLARE_GLOBAL_DATA_PTR
;
/**
* struct i2c_mux_gpio_priv - private data for i2c mux gpio
*
* @values: the reg value of each child node
* @n_values: num of regs
* @gpios: the mux-gpios array
* @n_gpios: num of gpios in mux-gpios
* @idle: the value of idle-state
*/
struct
i2c_mux_gpio_priv
{
u32
*
values
;
int
n_values
;
struct
gpio_desc
*
gpios
;
int
n_gpios
;
u32
idle
;
};
static
int
i2c_mux_gpio_select
(
struct
udevice
*
dev
,
struct
udevice
*
bus
,
uint
channel
)
{
struct
i2c_mux_gpio_priv
*
priv
=
dev_get_priv
(
dev
);
int
i
,
ret
;
for
(
i
=
0
;
i
<
priv
->
n_gpios
;
i
++
)
{
ret
=
dm_gpio_set_value
(
&
priv
->
gpios
[
i
],
(
channel
>>
i
)
&
1
);
if
(
ret
)
return
ret
;
}
return
0
;
}
static
int
i2c_mux_gpio_deselect
(
struct
udevice
*
dev
,
struct
udevice
*
bus
,
uint
channel
)
{
struct
i2c_mux_gpio_priv
*
priv
=
dev_get_priv
(
dev
);
int
i
,
ret
;
for
(
i
=
0
;
i
<
priv
->
n_gpios
;
i
++
)
{
ret
=
dm_gpio_set_value
(
&
priv
->
gpios
[
i
],
(
priv
->
idle
>>
i
)
&
1
);
if
(
ret
)
return
ret
;
}
return
0
;
}
static
int
i2c_mux_gpio_probe
(
struct
udevice
*
dev
)
{
const
void
*
fdt
=
gd
->
fdt_blob
;
int
node
=
dev_of_offset
(
dev
);
struct
i2c_mux_gpio_priv
*
mux
=
dev_get_priv
(
dev
);
struct
gpio_desc
*
gpios
;
u32
*
values
;
int
i
=
0
,
subnode
,
ret
;
mux
->
n_values
=
fdtdec_get_child_count
(
fdt
,
node
);
values
=
devm_kzalloc
(
dev
,
sizeof
(
*
mux
->
values
)
*
mux
->
n_values
,
GFP_KERNEL
);
if
(
!
values
)
{
dev_err
(
dev
,
"Cannot alloc values array"
);
return
-
ENOMEM
;
}
fdt_for_each_subnode
(
subnode
,
fdt
,
node
)
{
*
(
values
+
i
)
=
fdtdec_get_uint
(
fdt
,
subnode
,
"reg"
,
-
1
);
i
++
;
}
mux
->
values
=
values
;
mux
->
idle
=
fdtdec_get_uint
(
fdt
,
node
,
"idle-state"
,
-
1
);
mux
->
n_gpios
=
gpio_get_list_count
(
dev
,
"mux-gpios"
);
if
(
mux
->
n_gpios
<
0
)
{
dev_err
(
dev
,
"Missing mux-gpios property
\n
"
);
return
-
EINVAL
;
}
gpios
=
devm_kzalloc
(
dev
,
sizeof
(
struct
gpio_desc
)
*
mux
->
n_gpios
,
GFP_KERNEL
);
if
(
!
gpios
)
{
dev_err
(
dev
,
"Cannot allocate gpios array
\n
"
);
return
-
ENOMEM
;
}
ret
=
gpio_request_list_by_name
(
dev
,
"mux-gpios"
,
gpios
,
mux
->
n_gpios
,
GPIOD_IS_OUT_ACTIVE
);
if
(
ret
<=
0
)
{
dev_err
(
dev
,
"Failed to request mux-gpios
\n
"
);
return
ret
;
}
mux
->
gpios
=
gpios
;
return
0
;
}
static
const
struct
i2c_mux_ops
i2c_mux_gpio_ops
=
{
.
select
=
i2c_mux_gpio_select
,
.
deselect
=
i2c_mux_gpio_deselect
,
};
static
const
struct
udevice_id
i2c_mux_gpio_ids
[]
=
{
{
.
compatible
=
"i2c-mux-gpio"
,
},
{}
};
U_BOOT_DRIVER
(
i2c_mux_gpio
)
=
{
.
name
=
"i2c_mux_gpio"
,
.
id
=
UCLASS_I2C_MUX
,
.
of_match
=
i2c_mux_gpio_ids
,
.
ops
=
&
i2c_mux_gpio_ops
,
.
probe
=
i2c_mux_gpio_probe
,
.
priv_auto_alloc_size
=
sizeof
(
struct
i2c_mux_gpio_priv
),
};
drivers/i2c/stm32f7_i2c.c
0 → 100644
浏览文件 @
cc0427d2
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录