#include <common.h>
#include <dm.h>
#include <irq.h>
+#include <log.h>
+#include <malloc.h>
#include <p2sb.h>
#include <spl.h>
#include <asm-generic/gpio.h>
#include <asm/intel_pinctrl.h>
#include <asm/intel_pinctrl_defs.h>
#include <asm/arch/gpio.h>
-#include <asm/arch/itss.h>
+#include <asm/itss.h>
#include <dm/device-internal.h>
#include <dt-bindings/gpio/gpio.h>
+#include <linux/err.h>
#define GPIO_DW_SIZE(x) (sizeof(u32) * (x))
#define PAD_CFG_OFFSET(x, dw_num) ((x) + GPIO_DW_SIZE(dw_num))
*
* @comm: Community to search
* @gpio: Pad number to look up (assumed to be valid)
- * @return offset, 0 for first GPIO in community
+ * Return: offset, 0 for first GPIO in community
*/
static size_t relative_pad_in_comm(const struct pad_community *comm,
uint gpio)
*
* @comm: Community to search
* @relative_pad: Pad to look up
- * @return group number if found (see community_n_groups, etc.), or
+ * Return: group number if found (see community_n_groups, etc.), or
* -ESPIPE if no groups, or -ENOENT if not found
*/
static int pinctrl_group_index(const struct pad_community *comm,
*
* @pad: Pad to check
* @devp: Returns the device for that pad
- * @return 0 if OK, -ENOTBLK if no device was found for the given pin
+ * Return: 0 if OK, -ENOTBLK if no device was found for the given pin
*/
static int pinctrl_get_device(uint pad, struct udevice **devp)
{
/*
* We have to probe each one of these since the community link is only
- * attached in intel_pinctrl_ofdata_to_platdata().
+ * attached in intel_pinctrl_of_to_plat().
*/
uclass_foreach_dev_probe(UCLASS_PINCTRL, dev) {
struct intel_pinctrl_priv *priv = dev_get_priv(dev);
return 0;
}
}
- printf("pad %d not found\n", pad);
+ log_debug("pad %d not found\n", pad);
return -ENOTBLK;
}
irq = pcr_read32(dev, PAD_CFG1_OFFSET(pad_cfg_offset));
irq &= PAD_CFG1_IRQ_MASK;
if (!irq) {
- log_err("GPIO %u doesn't support APIC routing\n", cfg->pad);
+ if (spl_phase() > PHASE_TPL)
+ log_err("GPIO %u doesn't support APIC routing\n",
+ cfg->pad);
return -EPROTONOSUPPORT;
}
return config_value;
}
}
- log_err("Logical-to-Chipset mapping not found\n");
+ if (spl_phase() > PHASE_TPL)
+ log_err("Logical-to-Chipset mapping not found\n");
return -ENOENT;
}
*
* @dev: Pinctrl device containing the pad (see pinctrl_get_device())
* @cfg: Configuration to apply
- * @return 0 if OK, -ve on error
+ * Return: 0 if OK, -ve on error
*/
static int pinctrl_configure_pad(struct udevice *dev,
const struct pad_config *cfg)
return 0;
}
-u32 intel_pinctrl_get_config_reg_addr(struct udevice *dev, uint offset)
+u32 intel_pinctrl_get_config_reg_offset(struct udevice *dev, uint offset)
{
struct intel_pinctrl_priv *priv = dev_get_priv(dev);
const struct pad_community *comm = priv->comm;
return config_offset;
}
+u32 intel_pinctrl_get_config_reg_addr(struct udevice *dev, uint offset)
+{
+ uint config_offset = intel_pinctrl_get_config_reg_offset(dev, offset);
+
+ return (u32)(ulong)pcr_reg_address(dev, config_offset);
+}
+
u32 intel_pinctrl_get_config_reg(struct udevice *dev, uint offset)
{
- uint config_offset = intel_pinctrl_get_config_reg_addr(dev, offset);
+ uint config_offset = intel_pinctrl_get_config_reg_offset(dev, offset);
return pcr_read32(dev, config_offset);
}
const struct pad_community *comm = priv->comm;
int group;
+ if (IS_ENABLED(CONFIG_INTEL_PINCTRL_MULTI_ACPI_DEVICES))
+ return offset;
group = pinctrl_group_index(comm, offset);
/* If pad base is not set then use GPIO number as ACPI pin number */
return 0;
}
-int intel_pinctrl_ofdata_to_platdata(struct udevice *dev,
- const struct pad_community *comm,
- int num_cfgs)
+int intel_pinctrl_of_to_plat(struct udevice *dev,
+ const struct pad_community *comm, int num_cfgs)
{
- struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev);
+ struct p2sb_child_plat *pplat = dev_get_parent_plat(dev);
struct intel_pinctrl_priv *priv = dev_get_priv(dev);
- int ret;
if (!comm) {
- log_err("Cannot find community for pid %d\n", pplat->pid);
+ if (spl_phase() > PHASE_TPL)
+ log_err("Cannot find community for pid %d\n",
+ pplat->pid);
return -EDOM;
}
- ret = uclass_first_device_err(UCLASS_IRQ, &priv->itss);
- if (ret)
- return log_msg_ret("Cannot find ITSS", ret);
priv->comm = comm;
priv->num_cfgs = num_cfgs;
int intel_pinctrl_probe(struct udevice *dev)
{
struct intel_pinctrl_priv *priv = dev_get_priv(dev);
+ int ret;
priv->itss_pol_cfg = true;
+ ret = irq_first_device_type(X86_IRQT_ITSS, &priv->itss);
+ if (ret)
+ return log_msg_ret("Cannot find ITSS", ret);
return 0;
}