static int sysc_init_static_data()

in ti-sysc.c [3101:3180]


static int sysc_init_static_data(struct sysc *ddata)
{
	const struct soc_device_attribute *match;
	struct ti_sysc_platform_data *pdata;
	unsigned long features = 0;
	struct device_node *np;

	if (sysc_soc)
		return 0;

	sysc_soc = kzalloc(sizeof(*sysc_soc), GFP_KERNEL);
	if (!sysc_soc)
		return -ENOMEM;

	mutex_init(&sysc_soc->list_lock);
	INIT_LIST_HEAD(&sysc_soc->disabled_modules);
	INIT_LIST_HEAD(&sysc_soc->restored_modules);
	sysc_soc->general_purpose = true;

	pdata = dev_get_platdata(ddata->dev);
	if (pdata && pdata->soc_type_gp)
		sysc_soc->general_purpose = pdata->soc_type_gp();

	match = soc_device_match(sysc_soc_match);
	if (match && match->data)
		sysc_soc->soc = (int)match->data;

	/*
	 * Check and warn about possible old incomplete dtb. We now want to see
	 * simple-pm-bus instead of simple-bus in the dtb for genpd using SoCs.
	 */
	switch (sysc_soc->soc) {
	case SOC_AM3:
	case SOC_AM4:
	case SOC_4430 ... SOC_4470:
	case SOC_5430:
	case SOC_DRA7:
		np = of_find_node_by_path("/ocp");
		WARN_ONCE(np && of_device_is_compatible(np, "simple-bus"),
			  "ti-sysc: Incomplete old dtb, please update\n");
		break;
	default:
		break;
	}

	/* Ignore devices that are not available on HS and EMU SoCs */
	if (!sysc_soc->general_purpose) {
		switch (sysc_soc->soc) {
		case SOC_3430 ... SOC_3630:
			sysc_add_disabled(0x48304000);	/* timer12 */
			break;
		case SOC_AM3:
			sysc_add_disabled(0x48310000);  /* rng */
			break;
		default:
			break;
		}
	}

	match = soc_device_match(sysc_soc_feat_match);
	if (!match)
		return 0;

	if (match->data)
		features = (unsigned long)match->data;

	/*
	 * Add disabled devices to the list based on the module base.
	 * Note that this must be done before we attempt to access the
	 * device and have module revision checks working.
	 */
	if (features & DIS_ISP)
		sysc_add_disabled(0x480bd400);
	if (features & DIS_IVA)
		sysc_add_disabled(0x5d000000);
	if (features & DIS_SGX)
		sysc_add_disabled(0x50000000);

	return 0;
}