Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bhnd/cores/chipc/chipc.c
/*- | /*- | ||||
* Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org> | * Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org> | ||||
* Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com> | * Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com> | ||||
* Copyright (c) 2017 The FreeBSD Foundation | * Copyright (c) 2017 The FreeBSD Foundation | ||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* This software was developed by Landon Fuller under sponsorship from | * Portions of this software were developed by Landon Fuller | ||||
* the FreeBSD Foundation. | * under sponsorship from the FreeBSD Foundation. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer, | * notice, this list of conditions and the following disclaimer, | ||||
* without modification. | * without modification. | ||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | chipc_attach(device_t dev) | ||||
if (bootverbose) | if (bootverbose) | ||||
chipc_print_caps(sc->dev, &sc->caps); | chipc_print_caps(sc->dev, &sc->caps); | ||||
/* Attach all supported child devices */ | /* Attach all supported child devices */ | ||||
if ((error = chipc_add_children(sc))) | if ((error = chipc_add_children(sc))) | ||||
goto failed; | goto failed; | ||||
if ((error = bus_generic_attach(dev))) | /* | ||||
* Register ourselves with the bus; we're fully initialized and can | |||||
* response to ChipCommin API requests. | |||||
* | |||||
* Since our children may need access to ChipCommon, this must be done | |||||
* before attaching our children below (via bus_generic_attach). | |||||
*/ | |||||
if ((error = bhnd_register_provider(dev, BHND_SERVICE_CHIPC))) | |||||
goto failed; | goto failed; | ||||
/* Register ourselves with the bus */ | if ((error = bus_generic_attach(dev))) | ||||
if ((error = bhnd_register_provider(dev, BHND_SERVICE_CHIPC))) | |||||
goto failed; | goto failed; | ||||
return (0); | return (0); | ||||
failed: | failed: | ||||
device_delete_children(sc->dev); | device_delete_children(sc->dev); | ||||
if (sc->core_region != NULL) { | if (sc->core_region != NULL) { | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | chipc_add_children(struct chipc_softc *sc) | ||||
} | } | ||||
/* | /* | ||||
* PMU/PWR_CTRL | * PMU/PWR_CTRL | ||||
* | * | ||||
* On AOB ("Always on Bus") devices, the PMU core (if it exists) is | * On AOB ("Always on Bus") devices, the PMU core (if it exists) is | ||||
* attached directly to the bhnd(4) bus -- not chipc. | * attached directly to the bhnd(4) bus -- not chipc. | ||||
*/ | */ | ||||
if (sc->caps.pwr_ctrl || (sc->caps.pmu && !sc->caps.aob)) { | if (sc->caps.pmu && !sc->caps.aob) { | ||||
child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pmu", -1); | child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pmu", 0); | ||||
if (child == NULL) { | if (child == NULL) { | ||||
device_printf(sc->dev, "failed to add pmu\n"); | device_printf(sc->dev, "failed to add pmu\n"); | ||||
return (ENXIO); | |||||
} | |||||
} else if (sc->caps.pwr_ctrl) { | |||||
child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pwrctl", 0); | |||||
if (child == NULL) { | |||||
device_printf(sc->dev, "failed to add pwrctl\n"); | |||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
} | } | ||||
/* All remaining devices are SoC-only */ | /* All remaining devices are SoC-only */ | ||||
if (bhnd_get_attach_type(sc->dev) != BHND_ATTACH_NATIVE) | if (bhnd_get_attach_type(sc->dev) != BHND_ATTACH_NATIVE) | ||||
return (0); | return (0); | ||||
▲ Show 20 Lines • Show All 1,108 Lines • Show Last 20 Lines |