arm: stm32mp: bsec: migrate trace to log macro
Define LOG_CATEGORY, change pr_debug to dev_dbg and remove "bsec:" header as it is managed by log macro (dev->name is displayed) Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
This commit is contained in:
		
							parent
							
								
									711b5bc0a2
								
							
						
					
					
						commit
						b66bfdf238
					
				| 
						 | 
					@ -3,6 +3,8 @@
 | 
				
			||||||
 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
 | 
					 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define LOG_CATEGORY UCLASS_MISC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <common.h>
 | 
					#include <common.h>
 | 
				
			||||||
#include <dm.h>
 | 
					#include <dm.h>
 | 
				
			||||||
#include <log.h>
 | 
					#include <log.h>
 | 
				
			||||||
| 
						 | 
					@ -10,6 +12,7 @@
 | 
				
			||||||
#include <asm/io.h>
 | 
					#include <asm/io.h>
 | 
				
			||||||
#include <asm/arch/bsec.h>
 | 
					#include <asm/arch/bsec.h>
 | 
				
			||||||
#include <asm/arch/stm32mp1_smc.h>
 | 
					#include <asm/arch/stm32mp1_smc.h>
 | 
				
			||||||
 | 
					#include <dm/device_compat.h>
 | 
				
			||||||
#include <linux/arm-smccc.h>
 | 
					#include <linux/arm-smccc.h>
 | 
				
			||||||
#include <linux/iopoll.h>
 | 
					#include <linux/iopoll.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -160,7 +163,7 @@ static int bsec_power_safmem(u32 base, bool power)
 | 
				
			||||||
 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
 | 
					 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
 | 
				
			||||||
 * Return: 0 if no error
 | 
					 * Return: 0 if no error
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int bsec_shadow_register(u32 base, u32 otp)
 | 
					static int bsec_shadow_register(struct udevice *dev, u32 base, u32 otp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	u32 val;
 | 
						u32 val;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
| 
						 | 
					@ -168,7 +171,8 @@ static int bsec_shadow_register(u32 base, u32 otp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* check if shadowing of otp is locked */
 | 
						/* check if shadowing of otp is locked */
 | 
				
			||||||
	if (bsec_read_SR_lock(base, otp))
 | 
						if (bsec_read_SR_lock(base, otp))
 | 
				
			||||||
		pr_debug("bsec : OTP %d is locked and refreshed with 0\n", otp);
 | 
							dev_dbg(dev, "OTP %d is locked and refreshed with 0\n",
 | 
				
			||||||
 | 
								otp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* check if safemem is power up */
 | 
						/* check if safemem is power up */
 | 
				
			||||||
	val = readl(base + BSEC_OTP_STATUS_OFF);
 | 
						val = readl(base + BSEC_OTP_STATUS_OFF);
 | 
				
			||||||
| 
						 | 
					@ -203,7 +207,7 @@ static int bsec_shadow_register(u32 base, u32 otp)
 | 
				
			||||||
 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
 | 
					 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
 | 
				
			||||||
 * Return: 0 if no error
 | 
					 * Return: 0 if no error
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int bsec_read_shadow(u32 base, u32 *val, u32 otp)
 | 
					static int bsec_read_shadow(struct udevice *dev, u32 base, u32 *val, u32 otp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	*val = readl(base + BSEC_OTP_DATA_OFF + otp * sizeof(u32));
 | 
						*val = readl(base + BSEC_OTP_DATA_OFF + otp * sizeof(u32));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -217,11 +221,11 @@ static int bsec_read_shadow(u32 base, u32 *val, u32 otp)
 | 
				
			||||||
 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
 | 
					 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
 | 
				
			||||||
 * Return: 0 if no error
 | 
					 * Return: 0 if no error
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int bsec_write_shadow(u32 base, u32 val, u32 otp)
 | 
					static int bsec_write_shadow(struct udevice *dev, u32 base, u32 val, u32 otp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* check if programming of otp is locked */
 | 
						/* check if programming of otp is locked */
 | 
				
			||||||
	if (bsec_read_SW_lock(base, otp))
 | 
						if (bsec_read_SW_lock(base, otp))
 | 
				
			||||||
		pr_debug("bsec : OTP %d is lock, write will be ignore\n", otp);
 | 
							dev_dbg(dev, "OTP %d is lock, write will be ignore\n", otp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	writel(val, base + BSEC_OTP_DATA_OFF + otp * sizeof(u32));
 | 
						writel(val, base + BSEC_OTP_DATA_OFF + otp * sizeof(u32));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -236,16 +240,16 @@ static int bsec_write_shadow(u32 base, u32 val, u32 otp)
 | 
				
			||||||
 * after the function the otp data is not refreshed in shadow
 | 
					 * after the function the otp data is not refreshed in shadow
 | 
				
			||||||
 * Return: 0 if no error
 | 
					 * Return: 0 if no error
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int bsec_program_otp(long base, u32 val, u32 otp)
 | 
					static int bsec_program_otp(struct udevice *dev, long base, u32 val, u32 otp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	u32 ret;
 | 
						u32 ret;
 | 
				
			||||||
	bool power_up = false;
 | 
						bool power_up = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (bsec_read_SP_lock(base, otp))
 | 
						if (bsec_read_SP_lock(base, otp))
 | 
				
			||||||
		pr_debug("bsec : OTP %d locked, prog will be ignore\n", otp);
 | 
							dev_dbg(dev, "OTP %d locked, prog will be ignore\n", otp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (readl(base + BSEC_OTP_LOCK_OFF) & (1 << BSEC_LOCK_PROGRAM))
 | 
						if (readl(base + BSEC_OTP_LOCK_OFF) & (1 << BSEC_LOCK_PROGRAM))
 | 
				
			||||||
		pr_debug("bsec : Global lock, prog will be ignore\n");
 | 
							dev_dbg(dev, "Global lock, prog will be ignore\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* check if safemem is power up */
 | 
						/* check if safemem is power up */
 | 
				
			||||||
	if (!(readl(base + BSEC_OTP_STATUS_OFF) & BSEC_MODE_PWR_MASK)) {
 | 
						if (!(readl(base + BSEC_OTP_STATUS_OFF) & BSEC_MODE_PWR_MASK)) {
 | 
				
			||||||
| 
						 | 
					@ -298,21 +302,21 @@ static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp)
 | 
				
			||||||
	plat = dev_get_plat(dev);
 | 
						plat = dev_get_plat(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* read current shadow value */
 | 
						/* read current shadow value */
 | 
				
			||||||
	ret = bsec_read_shadow(plat->base, &tmp_data, otp);
 | 
						ret = bsec_read_shadow(dev, plat->base, &tmp_data, otp);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* copy otp in shadow */
 | 
						/* copy otp in shadow */
 | 
				
			||||||
	ret = bsec_shadow_register(plat->base, otp);
 | 
						ret = bsec_shadow_register(dev, plat->base, otp);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = bsec_read_shadow(plat->base, val, otp);
 | 
						ret = bsec_read_shadow(dev, plat->base, val, otp);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* restore shadow value */
 | 
						/* restore shadow value */
 | 
				
			||||||
	ret = bsec_write_shadow(plat->base, tmp_data, otp);
 | 
						ret = bsec_write_shadow(dev, plat->base, tmp_data, otp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -328,7 +332,7 @@ static int stm32mp_bsec_read_shadow(struct udevice *dev, u32 *val, u32 otp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	plat = dev_get_plat(dev);
 | 
						plat = dev_get_plat(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return bsec_read_shadow(plat->base, val, otp);
 | 
						return bsec_read_shadow(dev, plat->base, val, otp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int stm32mp_bsec_read_lock(struct udevice *dev, u32 *val, u32 otp)
 | 
					static int stm32mp_bsec_read_lock(struct udevice *dev, u32 *val, u32 otp)
 | 
				
			||||||
| 
						 | 
					@ -352,7 +356,7 @@ static int stm32mp_bsec_write_otp(struct udevice *dev, u32 val, u32 otp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	plat = dev_get_plat(dev);
 | 
						plat = dev_get_plat(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return bsec_program_otp(plat->base, val, otp);
 | 
						return bsec_program_otp(dev, plat->base, val, otp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -367,7 +371,7 @@ static int stm32mp_bsec_write_shadow(struct udevice *dev, u32 val, u32 otp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	plat = dev_get_plat(dev);
 | 
						plat = dev_get_plat(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return bsec_write_shadow(plat->base, val, otp);
 | 
						return bsec_write_shadow(dev, plat->base, val, otp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int stm32mp_bsec_write_lock(struct udevice *dev, u32 val, u32 otp)
 | 
					static int stm32mp_bsec_write_lock(struct udevice *dev, u32 val, u32 otp)
 | 
				
			||||||
| 
						 | 
					@ -497,7 +501,7 @@ static int stm32mp_bsec_probe(struct udevice *dev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (otp = 57; otp <= BSEC_OTP_MAX_VALUE; otp++)
 | 
							for (otp = 57; otp <= BSEC_OTP_MAX_VALUE; otp++)
 | 
				
			||||||
			if (!bsec_read_SR_lock(plat->base, otp))
 | 
								if (!bsec_read_SR_lock(plat->base, otp))
 | 
				
			||||||
				bsec_shadow_register(plat->base, otp);
 | 
									bsec_shadow_register(dev, plat->base, otp);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -527,7 +531,7 @@ bool bsec_dbgswenable(void)
 | 
				
			||||||
	ret = uclass_get_device_by_driver(UCLASS_MISC,
 | 
						ret = uclass_get_device_by_driver(UCLASS_MISC,
 | 
				
			||||||
					  DM_DRIVER_GET(stm32mp_bsec), &dev);
 | 
										  DM_DRIVER_GET(stm32mp_bsec), &dev);
 | 
				
			||||||
	if (ret || !dev) {
 | 
						if (ret || !dev) {
 | 
				
			||||||
		pr_debug("bsec driver not available\n");
 | 
							log_debug("bsec driver not available\n");
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue