mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
i2c: stm32f7_i2c: migrate trace to dev and log macro
Change debug to dev_dbg macro and define LOG_CATEGORY. Remove the "%s:" __func__ header as it is managed by dev macro (dev->name is displayed) or log macro (CONFIG_LOGF_FUNC). Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
ff2a09cede
commit
f4ed224d53
|
@ -3,6 +3,8 @@
|
||||||
* (C) Copyright 2017 STMicroelectronics
|
* (C) Copyright 2017 STMicroelectronics
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define LOG_CATEGORY UCLASS_I2C
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <clk.h>
|
#include <clk.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
@ -11,10 +13,10 @@
|
||||||
#include <regmap.h>
|
#include <regmap.h>
|
||||||
#include <reset.h>
|
#include <reset.h>
|
||||||
#include <syscon.h>
|
#include <syscon.h>
|
||||||
|
#include <dm/device.h>
|
||||||
|
#include <dm/device_compat.h>
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
|
||||||
#include <dm/device.h>
|
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
|
|
||||||
|
@ -346,7 +348,7 @@ static int stm32_i2c_wait_flags(struct stm32_i2c_priv *i2c_priv,
|
||||||
*status = readl(®s->isr);
|
*status = readl(®s->isr);
|
||||||
while (!(*status & flags)) {
|
while (!(*status & flags)) {
|
||||||
if (get_timer(time_start) > CONFIG_SYS_HZ) {
|
if (get_timer(time_start) > CONFIG_SYS_HZ) {
|
||||||
debug("%s: i2c timeout\n", __func__);
|
log_debug("i2c timeout\n");
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +371,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (status & STM32_I2C_ISR_BERR) {
|
if (status & STM32_I2C_ISR_BERR) {
|
||||||
debug("%s: Bus error\n", __func__);
|
log_debug("Bus error\n");
|
||||||
|
|
||||||
/* Clear BERR flag */
|
/* Clear BERR flag */
|
||||||
setbits_le32(®s->icr, STM32_I2C_ICR_BERRCF);
|
setbits_le32(®s->icr, STM32_I2C_ICR_BERRCF);
|
||||||
|
@ -378,7 +380,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status & STM32_I2C_ISR_ARLO) {
|
if (status & STM32_I2C_ISR_ARLO) {
|
||||||
debug("%s: Arbitration lost\n", __func__);
|
log_debug("Arbitration lost\n");
|
||||||
|
|
||||||
/* Clear ARLO flag */
|
/* Clear ARLO flag */
|
||||||
setbits_le32(®s->icr, STM32_I2C_ICR_ARLOCF);
|
setbits_le32(®s->icr, STM32_I2C_ICR_ARLOCF);
|
||||||
|
@ -387,7 +389,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status & STM32_I2C_ISR_NACKF) {
|
if (status & STM32_I2C_ISR_NACKF) {
|
||||||
debug("%s: Receive NACK\n", __func__);
|
log_debug("Receive NACK\n");
|
||||||
|
|
||||||
/* Clear NACK flag */
|
/* Clear NACK flag */
|
||||||
setbits_le32(®s->icr, STM32_I2C_ICR_NACKCF);
|
setbits_le32(®s->icr, STM32_I2C_ICR_NACKCF);
|
||||||
|
@ -535,8 +537,8 @@ static int stm32_i2c_compute_solutions(struct stm32_i2c_setup *setup,
|
||||||
if (sdadel_max < 0)
|
if (sdadel_max < 0)
|
||||||
sdadel_max = 0;
|
sdadel_max = 0;
|
||||||
|
|
||||||
debug("%s: SDADEL(min/max): %i/%i, SCLDEL(Min): %i\n", __func__,
|
log_debug("SDADEL(min/max): %i/%i, SCLDEL(Min): %i\n",
|
||||||
sdadel_min, sdadel_max, scldel_min);
|
sdadel_min, sdadel_max, scldel_min);
|
||||||
|
|
||||||
/* Compute possible values for PRESC, SCLDEL and SDADEL */
|
/* Compute possible values for PRESC, SCLDEL and SDADEL */
|
||||||
for (p = 0; p < STM32_PRESC_MAX; p++) {
|
for (p = 0; p < STM32_PRESC_MAX; p++) {
|
||||||
|
@ -572,7 +574,7 @@ static int stm32_i2c_compute_solutions(struct stm32_i2c_setup *setup,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_empty(solutions)) {
|
if (list_empty(solutions)) {
|
||||||
pr_err("%s: no Prescaler solution\n", __func__);
|
log_err("no Prescaler solution\n");
|
||||||
ret = -EPERM;
|
ret = -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,7 +658,7 @@ static int stm32_i2c_choose_solution(struct stm32_i2c_setup *setup,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sol_found) {
|
if (!sol_found) {
|
||||||
pr_err("%s: no solution at all\n", __func__);
|
log_err("no solution at all\n");
|
||||||
ret = -EPERM;
|
ret = -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,23 +688,22 @@ static int stm32_i2c_compute_timing(struct stm32_i2c_priv *i2c_priv,
|
||||||
|
|
||||||
specs = get_specs(setup->speed_freq);
|
specs = get_specs(setup->speed_freq);
|
||||||
if (specs == ERR_PTR(-EINVAL)) {
|
if (specs == ERR_PTR(-EINVAL)) {
|
||||||
pr_err("%s: speed out of bound {%d}\n", __func__,
|
log_err("speed out of bound {%d}\n",
|
||||||
setup->speed_freq);
|
setup->speed_freq);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setup->rise_time > specs->rise_max ||
|
if (setup->rise_time > specs->rise_max ||
|
||||||
setup->fall_time > specs->fall_max) {
|
setup->fall_time > specs->fall_max) {
|
||||||
pr_err("%s :timings out of bound Rise{%d>%d}/Fall{%d>%d}\n",
|
log_err("timings out of bound Rise{%d>%d}/Fall{%d>%d}\n",
|
||||||
__func__,
|
setup->rise_time, specs->rise_max,
|
||||||
setup->rise_time, specs->rise_max,
|
setup->fall_time, specs->fall_max);
|
||||||
setup->fall_time, specs->fall_max);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setup->dnf > STM32_I2C_DNF_MAX) {
|
if (setup->dnf > STM32_I2C_DNF_MAX) {
|
||||||
pr_err("%s: DNF out of bound %d/%d\n", __func__,
|
log_err("DNF out of bound %d/%d\n",
|
||||||
setup->dnf, STM32_I2C_DNF_MAX);
|
setup->dnf, STM32_I2C_DNF_MAX);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,10 +716,10 @@ static int stm32_i2c_compute_timing(struct stm32_i2c_priv *i2c_priv,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
debug("%s: Presc: %i, scldel: %i, sdadel: %i, scll: %i, sclh: %i\n",
|
log_debug("Presc: %i, scldel: %i, sdadel: %i, scll: %i, sclh: %i\n",
|
||||||
__func__, output->presc,
|
output->presc,
|
||||||
output->scldel, output->sdadel,
|
output->scldel, output->sdadel,
|
||||||
output->scll, output->sclh);
|
output->scll, output->sclh);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
/* Release list and memory */
|
/* Release list and memory */
|
||||||
|
@ -751,20 +752,19 @@ static int stm32_i2c_setup_timing(struct stm32_i2c_priv *i2c_priv,
|
||||||
setup->clock_src = clk_get_rate(&i2c_priv->clk);
|
setup->clock_src = clk_get_rate(&i2c_priv->clk);
|
||||||
|
|
||||||
if (!setup->clock_src) {
|
if (!setup->clock_src) {
|
||||||
pr_err("%s: clock rate is 0\n", __func__);
|
log_err("clock rate is 0\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = stm32_i2c_compute_timing(i2c_priv, setup, timing);
|
ret = stm32_i2c_compute_timing(i2c_priv, setup, timing);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
debug("%s: failed to compute I2C timings.\n",
|
log_debug("failed to compute I2C timings.\n");
|
||||||
__func__);
|
|
||||||
if (setup->speed_freq > I2C_SPEED_STANDARD_RATE) {
|
if (setup->speed_freq > I2C_SPEED_STANDARD_RATE) {
|
||||||
setup->speed_freq =
|
setup->speed_freq =
|
||||||
get_lower_rate(setup->speed_freq);
|
get_lower_rate(setup->speed_freq);
|
||||||
debug("%s: downgrade I2C Speed Freq to (%i)\n",
|
log_debug("downgrade I2C Speed Freq to (%i)\n",
|
||||||
__func__, setup->speed_freq);
|
setup->speed_freq);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -772,16 +772,16 @@ static int stm32_i2c_setup_timing(struct stm32_i2c_priv *i2c_priv,
|
||||||
} while (ret);
|
} while (ret);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_err("%s: impossible to compute I2C timings.\n", __func__);
|
log_err("impossible to compute I2C timings.\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("%s: I2C Freq(%i), Clk Source(%i)\n", __func__,
|
log_debug("I2C Freq(%i), Clk Source(%i)\n",
|
||||||
setup->speed_freq, setup->clock_src);
|
setup->speed_freq, setup->clock_src);
|
||||||
debug("%s: I2C Rise(%i) and Fall(%i) Time\n", __func__,
|
log_debug("I2C Rise(%i) and Fall(%i) Time\n",
|
||||||
setup->rise_time, setup->fall_time);
|
setup->rise_time, setup->fall_time);
|
||||||
debug("%s: I2C Analog Filter(%s), DNF(%i)\n", __func__,
|
log_debug("I2C Analog Filter(%s), DNF(%i)\n",
|
||||||
setup->analog_filter ? "On" : "Off", setup->dnf);
|
setup->analog_filter ? "On" : "Off", setup->dnf);
|
||||||
|
|
||||||
i2c_priv->speed = setup->speed_freq;
|
i2c_priv->speed = setup->speed_freq;
|
||||||
|
|
||||||
|
@ -848,12 +848,12 @@ static int stm32_i2c_hw_config(struct stm32_i2c_priv *i2c_priv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stm32_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
|
static int stm32_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
|
||||||
{
|
{
|
||||||
struct stm32_i2c_priv *i2c_priv = dev_get_priv(bus);
|
struct stm32_i2c_priv *i2c_priv = dev_get_priv(dev);
|
||||||
|
|
||||||
if (speed > I2C_SPEED_FAST_PLUS_RATE) {
|
if (speed > I2C_SPEED_FAST_PLUS_RATE) {
|
||||||
debug("%s: Speed %d not supported\n", __func__, speed);
|
dev_dbg(dev, "Speed %d not supported\n", speed);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user