Commit 68545c1a authored by Tom Rini's avatar Tom Rini
Browse files

Merge tag '20210928-for-next' of https://source.denx.de/u-boot/custodians/u-boot-i2c into next

i2c changes for 20210928-for-next

- i2c: rcar_i2c: Enable configuring SCL rise and fall times
- i2c: mvtwsi: Add support for DM clocks and resets
- mtd: nand: raw: convert nand_dt_init() to ofnode_xx() interface
parents 1d1f98c8 a70c3f9f
......@@ -17,7 +17,9 @@
#include <linux/bitops.h>
#include <linux/compat.h>
#if CONFIG_IS_ENABLED(DM_I2C)
#include <clk.h>
#include <dm.h>
#include <reset.h>
#endif
DECLARE_GLOBAL_DATA_PTR;
......@@ -835,7 +837,18 @@ static int mvtwsi_i2c_bind(struct udevice *bus)
static int mvtwsi_i2c_probe(struct udevice *bus)
{
struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
struct reset_ctl reset;
struct clk clk;
uint actual_speed;
int ret;
ret = reset_get_by_index(bus, 0, &reset);
if (!ret)
reset_deassert(&reset);
ret = clk_get_by_index(bus, 0, &clk);
if (!ret)
clk_enable(&clk);
__twsi_i2c_init(dev->base, dev->speed, dev->slaveadd, &actual_speed);
dev->speed = actual_speed;
......
......@@ -64,6 +64,8 @@ enum rcar_i2c_type {
struct rcar_i2c_priv {
void __iomem *base;
struct clk clk;
u32 fall_ns;
u32 rise_ns;
u32 intdelay;
u32 icccr;
enum rcar_i2c_type type;
......@@ -278,7 +280,7 @@ static int rcar_i2c_set_speed(struct udevice *dev, uint bus_freq_hz)
* = F[sum * ick / 1000000000]
* = F[(ick / 1000000) * sum / 1000]
*/
sum = 35 + 200 + priv->intdelay;
sum = priv->fall_ns + priv->rise_ns + priv->intdelay;
round = (ick + 500000) / 1000000 * sum;
round = (round + 500) / 1000;
......@@ -323,6 +325,10 @@ static int rcar_i2c_probe(struct udevice *dev)
int ret;
priv->base = dev_read_addr_ptr(dev);
priv->rise_ns = dev_read_u32_default(dev,
"i2c-scl-rising-time-ns", 200);
priv->fall_ns = dev_read_u32_default(dev,
"i2c-scl-falling-time-ns", 35);
priv->intdelay = dev_read_u32_default(dev,
"i2c-scl-internal-delay-ns", 5);
priv->type = dev_get_driver_data(dev);
......
......@@ -1246,7 +1246,7 @@ int denali_init(struct denali_nand_info *denali)
denali->active_bank = DENALI_INVALID_BANK;
chip->flash_node = dev_of_offset(denali->dev);
chip->flash_node = dev_ofnode(denali->dev);
/* Fallback to the default name if DT did not give "label" property */
if (!mtd->name)
mtd->name = "denali-nand";
......
......@@ -1379,7 +1379,7 @@ int mxs_nand_init_ctrl(struct mxs_nand_info *nand_info)
nand->options |= NAND_NO_SUBPAGE_WRITE;
if (nand_info->dev)
nand->flash_node = dev_of_offset(nand_info->dev);
nand->flash_node = dev_ofnode(nand_info->dev);
nand->cmd_ctrl = mxs_nand_cmd_ctrl;
......
......@@ -29,9 +29,6 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <common.h>
#if CONFIG_IS_ENABLED(OF_CONTROL)
#include <fdtdec.h>
#endif
#include <log.h>
#include <malloc.h>
#include <watchdog.h>
......@@ -4576,23 +4573,20 @@ ident_done:
EXPORT_SYMBOL(nand_get_flash_type);
#if CONFIG_IS_ENABLED(OF_CONTROL)
#include <asm/global_data.h>
DECLARE_GLOBAL_DATA_PTR;
static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, int node)
static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode node)
{
int ret, ecc_mode = -1, ecc_strength, ecc_step;
const void *blob = gd->fdt_blob;
const char *str;
ret = fdtdec_get_int(blob, node, "nand-bus-width", -1);
ret = ofnode_read_s32_default(node, "nand-bus-width", -1);
if (ret == 16)
chip->options |= NAND_BUSWIDTH_16;
if (fdtdec_get_bool(blob, node, "nand-on-flash-bbt"))
if (ofnode_read_bool(node, "nand-on-flash-bbt"))
chip->bbt_options |= NAND_BBT_USE_FLASH;
str = fdt_getprop(blob, node, "nand-ecc-mode", NULL);
str = ofnode_read_string(node, "nand-ecc-mode");
if (str) {
if (!strcmp(str, "none"))
ecc_mode = NAND_ECC_NONE;
......@@ -4608,9 +4602,10 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, int node)
ecc_mode = NAND_ECC_SOFT_BCH;
}
ecc_strength = fdtdec_get_int(blob, node, "nand-ecc-strength", -1);
ecc_step = fdtdec_get_int(blob, node, "nand-ecc-step-size", -1);
ecc_strength = ofnode_read_s32_default(node,
"nand-ecc-strength", -1);
ecc_step = ofnode_read_s32_default(node,
"nand-ecc-step-size", -1);
if ((ecc_step >= 0 && !(ecc_strength >= 0)) ||
(!(ecc_step >= 0) && ecc_strength >= 0)) {
......@@ -4627,13 +4622,13 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, int node)
if (ecc_step > 0)
chip->ecc.size = ecc_step;
if (fdt_getprop(blob, node, "nand-ecc-maximize", NULL))
if (ofnode_read_bool(node, "nand-ecc-maximize"))
chip->ecc.options |= NAND_ECC_MAXIMIZE;
return 0;
}
#else
static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, int node)
static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode node)
{
return 0;
}
......@@ -4657,7 +4652,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
struct nand_flash_dev *type;
int ret;
if (chip->flash_node) {
if (ofnode_valid(chip->flash_node)) {
ret = nand_dt_init(mtd, chip, chip->flash_node);
if (ret)
return ret;
......
......@@ -823,7 +823,7 @@ static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc, ofnode node)
nand->cs_used[i] = cs[i];
}
nand->chip.flash_node = ofnode_to_offset(node);
nand->chip.flash_node = node;
return 0;
}
......
......@@ -1711,7 +1711,7 @@ static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum)
* in the DT.
*/
nand->ecc.mode = NAND_ECC_HW;
nand->flash_node = node;
nand->flash_node = offset_to_ofnode(node);
nand->select_chip = sunxi_nfc_select_chip;
nand->cmd_ctrl = sunxi_nfc_cmd_ctrl;
nand->read_buf = sunxi_nfc_read_buf;
......
......@@ -891,7 +891,7 @@ struct nand_chip {
void __iomem *IO_ADDR_R;
void __iomem *IO_ADDR_W;
int flash_node;
ofnode flash_node;
uint8_t (*read_byte)(struct mtd_info *mtd);
u16 (*read_word)(struct mtd_info *mtd);
......@@ -973,12 +973,12 @@ struct nand_chip {
static inline void nand_set_flash_node(struct nand_chip *chip,
ofnode node)
{
chip->flash_node = ofnode_to_offset(node);
chip->flash_node = node;
}
static inline ofnode nand_get_flash_node(struct nand_chip *chip)
{
return offset_to_ofnode(chip->flash_node);
return chip->flash_node;
}
static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment