Beispiel #1
0
/**
 *	ti_scm_padconf_init_from_hints - processes the hints for padconf
 *	@sc: the driver soft context
 *
 *	
 *
 *	LOCKING:
 *	Internally locks it's own context.
 *
 *	RETURNS:
 *	0 on success.
 *	EINVAL if pin requested is outside valid range or already in use.
 */
static int
ti_scm_padconf_init_from_fdt(struct ti_scm_softc *sc)
{
	const struct ti_scm_padconf *padconf;
	const struct ti_scm_padstate *padstates;
	int err;
	phandle_t node;
	int len;
	char *fdt_pad_config;
	int i;
	char *padname, *muxname, *padstate;

	node = ofw_bus_get_node(sc->sc_dev);
	len = OF_getproplen(node, "scm-pad-config");
        OF_getprop_alloc(node, "scm-pad-config", 1, (void **)&fdt_pad_config);

	i = len;
	while (i > 0) {
		padname = fdt_pad_config;
		fdt_pad_config += strlen(padname) + 1;
		i -= strlen(padname) + 1;
		if (i <= 0)
			break;

		muxname = fdt_pad_config;
		fdt_pad_config += strlen(muxname) + 1;
		i -= strlen(muxname) + 1;
		if (i <= 0)
			break;

		padstate = fdt_pad_config;
		fdt_pad_config += strlen(padstate) + 1;
		i -= strlen(padstate) + 1;
		if (i < 0)
			break;

		padconf = ti_scm_dev.padconf;

		while (padconf->ballname != NULL) {
			if (strcmp(padconf->ballname, padname) == 0) {
				padstates = ti_scm_dev.padstate;
				err = 1;
				while (padstates->state != NULL) {
					if (strcmp(padstates->state, padstate) == 0) {
						err = ti_scm_padconf_set_internal(sc,
							padconf, muxname, padstates->reg);
					}
					padstates++;
				}
				if (err)
					device_printf(sc->sc_dev, "err: failed to configure"
						"pin \"%s\"\n", padconf->ballname);
			}
			padconf++;
		}
	}
	return (0);
}
Beispiel #2
0
/**
 *	ti_scm_padconf_set - sets the muxmode and state for a pad/pin
 *	@padname: the name of the pad, i.e. "c12"
 *	@muxmode: the name of the mode to use for the pin, i.e. "uart1_rx"
 *	@state: the state to put the pad/pin in, i.e. PADCONF_PIN_???
 *	
 *
 *	LOCKING:
 *	Internally locks it's own context.
 *
 *	RETURNS:
 *	0 on success.
 *	EINVAL if pin requested is outside valid range or already in use.
 */
int
ti_scm_padconf_set(const char *padname, const char *muxmode, unsigned int state)
{
	const struct ti_scm_padconf *padconf;

	if (!ti_scm_sc)
		return (ENXIO);

	/* find the pin in the devmap */
	padconf = ti_scm_padconf_from_name(padname);
	if (padconf == NULL)
		return (EINVAL);
	
	return (ti_scm_padconf_set_internal(ti_scm_sc, padconf, muxmode, state));
}