aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/extres
Commit message (Collapse)AuthorAgeFilesLines
* regulator: Use bool values instead of 0/1Emmanuel Vadot2018-09-041-5/+6
| | | | | | | | | | | While here do not attempt to disable regulators if they are meant to be always on. Reviewed by: mmel Approved by: re (kib) Notes: svn path=/head/; revision=338457
* extres: clkdiv: Fix div_with_tableEmmanuel Vadot2018-08-051-9/+13
| | | | | | | | | We didn't allowed a divider register value of 0 which can exists and also didn't wrote the value but the divider, which result of a wrong frequency to be selected Notes: svn path=/head/; revision=337346
* nvmem: Add nvmem interface and helpersEmmanuel Vadot2018-07-313-0/+303
| | | | | | | | | | | The nvmem interface helps provider of nvmem data to expose themselves to consumer. NVMEM is generally present on some embedded board in a form of eeprom or fuses. The nvmem api are helpers for consumer to read/write the cell data from a provider. Differential Revision: https://reviews.freebsd.org/D16419 Notes: svn path=/head/; revision=336996
* Fix handling of enable counter for shared GPIO line in fixed regulator.Michal Meloun2018-06-163-4/+65
| | | | | | | | | | | | | | | | | | | | | | | | | For most regulators, the regulator_stop() method can be transformed to regulator disable. But, in some cases, we needs to maintain shared data across multiple regulators (e.g. single GPIO pin which works as enable for multiple regulates). In this case, the implementation of regulator should perform his own enable counting therefore it is necessary to distinguish between the regulator enable/disable method (which increments/decrements enable counter for shared resource) and regulator stop method (which don't affect it). So: - add regnode_stop() method to regulator framework and default it to regnode_enable(..., false, ...) - implement it in regulator_fixed with proper enable counting. While I'm in, also fix handling of always_on property. If any of regulators sharing same GPIO pin have it enabled, then none of them can disable regulator. Tested by: kevans MFC after: 3 weeks Notes: svn path=/head/; revision=335249
* extres/regulator: Switch boot_on/always_on sysctl to uint8Kyle Evans2018-06-151-4/+4
| | | | | | | | | | | | These are represented as booleans on the kernel-side, but were being exposed as int. This was causing some funky things to happen when read later with sysctl(8), e.g. randomly reading super-high when the value was actually '0'/false. Reviewed by: manu Notes: svn path=/head/; revision=335220
* Revert r335173 at request of mmel@Kyle Evans2018-06-153-20/+0
| | | | | | | | | | | | This was the wrong solution to the problem; regulator_shutdown invokes regnode_stop. regulator_stop is not a refcounting method, but it invokes regnode_enable, which is. mmel@ has a proposed patch/solution to instead provide regnode_fixed_stop behavior that properly takes shared GPIO pins into account. Notes: svn path=/head/; revision=335195
* extres/regulator: Properly refcount gpio regulatorsKyle Evans2018-06-143-0/+20
| | | | | | | | | | | | | | | | | regnode::enable_cnt is generally used to refcount regulator nodes. For GPIOs, the refcount was done on the gpio_entry since more than one regulator can share a GPIO. GPIO regulators were not taking part in the node refcount, since they had their own mechanism. This caused some fallout after manu started disabling everybody's unused regulators in r331989. Refcount it. Glanced over by: manu Notes: svn path=/head/; revision=335173
* regulator: Fix typo (shuting/shutting)Emmanuel Vadot2018-05-301-1/+1
| | | | | | | Submitted by: Jose Luis Duran (github pull #151) Notes: svn path=/head/; revision=334386
* Remove "All Rights Reserved" on files that I hold sole copyright onKyle Evans2018-05-093-3/+0
| | | | | | | | See r333391 for more detail; in summary: it holds no weight and may be removed. Notes: svn path=/head/; revision=333418
* clk: clk_set_assigned: Skip frequency of value 0Emmanuel Vadot2018-05-071-1/+1
| | | | | | | | A frequency of value 0 mean that we don't want to change the frequency so skip it. Notes: svn path=/head/; revision=333320
* clk: Add support for assigned-clock-ratesEmmanuel Vadot2018-05-071-24/+76
| | | | | | | | | | | | The properties 'assigned-clocks', 'assigned-clock-parents' and 'assigned-clock-rates' all work together. 'assigned-clocks' holds the list of clock for which we need to either assign a new parent or a new frequency. The old code just supported assigning a new parents, add support for assigning a new frequency too. Notes: svn path=/head/; revision=333318
* clk: Put the sysctls under hw.clock instead of clockEmmanuel Vadot2018-04-271-1/+3
| | | | | | | | This is more consistant with hw.regulator and other hardware related sysctls. Notes: svn path=/head/; revision=333047
* regulator: Check status before disablingEmmanuel Vadot2018-04-201-3/+5
| | | | | | | | | | | | | | | | When disabling regulator when they are unused, check before is they are enabled. While here don't check the enable_cnt on the regulator entry as it is checked by regnode_stop. This solve the panic on any board using a fixed regulator that is driven by a gpio when the regulator is unused. Tested On: OrangePi One Pointy Hat to: myself Reported by: kevans, Milan Obuch (freebsd-arm@dino.sk) Notes: svn path=/head/; revision=332843
* Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_allocOleksandr Tymoshenko2018-04-094-4/+4
| | | | | | | | | | | | | | | | | | | | | Change OF_getencprop_alloc semantics to be combination of malloc and OF_getencprop and return size of the property, not number of elements allocated. For the use cases where number of elements is preferred introduce OF_getencprop_alloc_multi helper function that copies semantics of OF_getencprop_alloc prior to this change. This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi function signatures consistent with OF_getencprop_alloc and OF_getencprop_alloc_multi. Functionality-wise this patch is mostly rename of OF_getencprop_alloc to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo where 1 was used as a block size. Notes: svn path=/head/; revision=332341
* Clean up OF_getprop_alloc APIOleksandr Tymoshenko2018-04-081-2/+2
| | | | | | | | | | | | | | | | | | | | OF_getprop_alloc takes element size argument and returns number of elements in the property. There are valid use cases for such behavior but mostly API consumers pass 1 as element size to get string properties. What API users would expect from OF_getprop_alloc is to be a combination of malloc + OF_getprop with the same semantic of return value. This patch modifies API signature to match these expectations. For the valid use cases with element size != 1 and to reduce modification scope new OF_getprop_alloc_multi function has been introduced that behaves the same way OF_getprop_alloc behaved prior to this patch. Reviewed by: ian, manu Differential Revision: https://reviews.freebsd.org/D14850 Notes: svn path=/head/; revision=332310
* regulator: Disable unused regulatorEmmanuel Vadot2018-04-041-0/+31
| | | | | | | | | | | | | | | | | | | bootloaders such as u-boot might enable regulators, or simply regulators could be enabled by default by the PMIC, even if we don't have a driver for the device or subsystem. Disable unused regulators just before going to userland. A tunable hw.regulator.disable_unused is added to not disable them in case this causes problems on some board but the default behavior is to disable everything unused. I prefer to break thinks now and fix them rather than never switch to the case were we disable regulators. Tested on : Pine64-LTS (an idle board goes from ~0.33A to ~0.27A) Tested on : BananaPi M2 Differential Revision: https://reviews.freebsd.org/D14781 Notes: svn path=/head/; revision=331989
* extres/regulators: Add sysctls for regulatorsEmmanuel Vadot2018-03-112-0/+91
| | | | | | | | | | | | | | | | | | | | For each regulators create an hw.regulator.<regname>. : uvolt: Current value always_on: 1 If the reg is always on boot_on: 1 If the reg is set at boot time enable_cnt: Number of consumer(s) enable_delay: Delay before enabling the regulator ramp_delay: The Ramp delay max_uamp: The maximum value of the regulator in uAmps min_uamp: The minimal value of the regulator in uAmps max_uvolt: The maximum value of the regulator in uVolts min_uvolt: The minimal value of the regulator in uVolts Reviewed by: ian Differential Revision: https://reviews.freebsd.org/D14578 Notes: svn path=/head/; revision=330758
* Define meaning of remaining clock rounding flags combinations.Michal Meloun2018-02-271-0/+4
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=330074
* Use more verbose panic messages.Michal Meloun2018-01-301-4/+5
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=328586
* Revert r328511, it was committed with <patch>.diff instead of <patch>.txt asMichal Meloun2018-01-301-5/+4
| | | | | | | commit log. Notes: svn path=/head/; revision=328585
* diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.cMichal Meloun2018-01-281-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | index c6a1f466ceb..c3708a0ce27 100644 --- a/sys/dev/extres/clk/clk.c +++ b/sys/dev/extres/clk/clk.c @@ -642,10 +642,11 @@ clknode_adjust_parent(struct clknode *clknode, int idx) if (clknode->parent_cnt == 0) return; if ((idx == CLKNODE_IDX_NONE) || (idx >= clknode->parent_cnt)) - panic("Invalid clock parent index\n"); + panic("%s: Invalid parent index %d for clock %s", + __func__, idx, clknode->name); if (clknode->parents[idx] == NULL) - panic("%s: Attempt to set invalid parent %d for clock %s", + panic("%s: Invalid parent index %d for clock %s", __func__, idx, clknode->name); /* Remove me from old children list. */ @@ -674,8 +675,8 @@ clknode_init_parent_idx(struct clknode *clknode, int idx) if ((idx == CLKNODE_IDX_NONE) || (idx >= clknode->parent_cnt) || (clknode->parent_names[idx] == NULL)) - panic("%s: Invalid clock parent index: %d\n", __func__, idx); - + panic("%s: Invalid parent index %d for clock %s", + __func__, idx, clknode->name); clknode->parent_idx = idx; } Notes: svn path=/head/; revision=328511
* Convert extres/phy to kobj model.Michal Meloun2018-01-204-97/+502
| | | | | | | | | | | | | | Similarly as other extres pseudo-drivers, implement phy by using kobj model. This detaches it from provider device, so single device driver can export multiple different phys. Additionally, this allows phy to be subclassed to more specialized drivers, like is USB OTG phy, or PCIe phy with hot-plug capability. Tested by: manu (previous version, on Allwinner board) MFC after: 1 month Notes: svn path=/head/; revision=328201
* clk: Get new parent freq after set_freqEmmanuel Vadot2018-01-201-0/+8
| | | | | | | | | | | During set_freq a clknode might have reparent (using a better parent that have a higher frequency for example), before refreshing the cache, re-get the parent frequency. Reviewed by: mmel Notes: svn path=/head/; revision=328198
* Add SPDX tags to syscon bits, correct inconsistency in Copyright line.Kyle Evans2018-01-134-2/+10
| | | | Notes: svn path=/head/; revision=327938
* Introduce aw_syscon(4) for earlier attachmentKyle Evans2018-01-132-18/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Attaching syscon_generic earlier than BUS_PASS_DEFAULT makes it more difficult for specific syscon drivers to attach to the syscon node and to get ordering right. Further discussion yielded the following set of decisions: - Move syscon_generic to BUS_PASS_DEFAULT - If a platform needs a syscon with different attach order or probe behavior, it should subclass syscon_generic and match on the SoC specific compat string - When we come across a need for a syscon that attaches earlier but only specifies compatible = "syscon", we should create a syscon_exclusive driver that provides generic access but probes earlier and only matches if "syscon" is the only compatible. Such fdt nodes do exist in the wild right now, but we don't really use them at the moment. Additionally: - Any syscon provider that has needs any more complex than a spinlock solely for syscon access and a single memory resource should subclass syscon directly rather than attempting to subclass syscon_generic or add complexity to it. syscon_generic's attach/detach methods may be made public should the need arise to subclass it with additional attach/detach behavior. We introduce aw_syscon(4) that just subclasses syscon_generic but probes earlier to meet our requirements for if_awg and implements #2 above for this specific situation. It currently only matches a64/a83t/h3 since these are the only platforms that really need it at the time being. Discussed with: ian Reviewed by: manu, andrew, bcr (manpages, content unchanged since review) Differential Revision: https://reviews.freebsd.org/D13793 Notes: svn path=/head/; revision=327936
* Fix bogus pass for syscon_generic introduced in r327621Kyle Evans2018-01-071-1/+6
| | | | | | | | | | | | | | ian@ pointed out that BUS_PASS_DEFAULT + $anything is bogus, given that BUS_PASS_DEFAULT is defined as __INT_MAX. Instead, we take a page out of imx6_usbphy's book and use BUS_PASS_DEFAULT - 1000 to achieve the desired effect of syscon_generic attaching before if_awg and other potential consumers, but late enough that more specialized implementations should have no problem attaching instead. Reported by: ian Notes: svn path=/head/; revision=327665
* Move syscon_generic to attach much laterKyle Evans2018-01-061-1/+1
| | | | | | | | | | | | | | | | It still needs to be before if_awg at least in order to be available for other operations, but it should not be attaching before interrupt controllers at the very least. This should make errors involving syscon register space colliding with other devices a little more innocent, but these conflicts should really be tracked down and resolved. One such conflict is with the Raspberry Pi 3 local interrupt controller, noticed by tuexen@ Reported by: tuexen Notes: svn path=/head/; revision=327621
* extres/syscon: Commit missing bits from r327106Kyle Evans2017-12-261-98/+168
| | | | | | | | | | | | | r327106 introduced kobj to syscon so it can be subclassed and fit in with the rest of the syscon framework. The diff for syscon.c was misapplied in a clean tree prior to commit, so bring it back to what was included in the review and tested. The entire file has basically been rewritten from what was present prior to the kobj work. Pointy hat to: me Notes: svn path=/head/; revision=327215
* Do pass removing some write-only variables from the kernel.Alexander Kabaev2017-12-252-4/+0
| | | | | | | | | | | | This reduces noise when kernel is compiled by newer GCC versions, such as one used by external toolchain ports. Reviewed by: kib, andrew(sys/arm and sys/arm64), emaste(partial), erj(partial) Reviewed by: jhb (sys/dev/pci/* sys/kern/vfs_aio.c and sys/kern/kern_synch.c) Differential Revision: https://reviews.freebsd.org/D10385 Notes: svn path=/head/; revision=327173
* Move syscon into extres frameworkKyle Evans2017-12-234-0/+537
| | | | | | | | | This should help reduce confusion between syscon/syscons a little bit. syscon is a resource generally modeled by FDT platforms, and not to be confused with syscons. Notes: svn path=/head/; revision=327107
* Remove redundant declarations. Newer gcc has a warning for these so willAndrew Turner2017-08-191-2/+0
| | | | | | | | | fail when building with -Werror. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=322697
* Export a sysctl dev.<clkdom>.<unit>.clocks for each clock domain containingEmmanuel Vadot2017-03-051-0/+118
| | | | | | | | | | | | | | | | | | | | | all the clocks that they provide. Each clocks are exported under the node 'clock.<clkname>' and have the following children nodes : - frequency - parent (The selected parent, if any) - parents (The list of parents, if any) - childrens (The list of childrens, if any) - enable_cnt (The enabled counter) This give us the possibility to examine clocks at runtime and make graph of the clock flow. Reviewed by: mmel MFC after: 2 month Differential Revision: https://reviews.freebsd.org/D9833 Notes: svn path=/head/; revision=314699
* Do not check divider length if we have a div table.Emmanuel Vadot2017-02-231-1/+2
| | | | | | | Reviewed by: mmel Notes: svn path=/head/; revision=314119
* clk_div: Add a div lookup tableEmmanuel Vadot2016-12-122-0/+49
| | | | | | | | | | | | Some clocks on SoC have a diff between the value written in the register and the real divider. Add a table that where we can lookup the real value of the divider. Reviewed by: mmel (earlier revision) Differential Revision: https://reviews.freebsd.org/D8728 Notes: svn path=/head/; revision=309894
* Clock framework fixes:Michal Meloun2016-12-041-5/+7
| | | | | | | | | | | - The clk_test_freq() (aka CLK_SET_DRYRUN) doesn't change frequency, don't cache it result. - Fix busy condition for clk_set_freq(). MFC after: 3 weeks Notes: svn path=/head/; revision=309537
* Do not warn if the 'assigned-clock-parents' property does not exists.Emmanuel Vadot2016-11-081-1/+3
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=308440
* Add clk_set_assignedEmmanuel Vadot2016-11-042-2/+50
| | | | | | | | | | | assigned-clock-parents are DT properties used to configure some default parent clocks on one node. Reviewed by: mmel MFC after: 2 weeks Notes: svn path=/head/; revision=308298
* REGULATOR: Move functions for handling with regulator ranges toMichal Meloun2016-10-182-0/+105
| | | | | | | | | common file. They can be useful for other PMICs. MFC after: 2 weeks Notes: svn path=/head/; revision=307558
* EXTRES: Add OF node as argument to all <foo>_get_by_ofw_<bar>() functions.Michal Meloun2016-07-109-51/+59
| | | | | | | | | | | In some cases, the driver must handle given properties located in specific OF subnode. Instead of creating duplicate set of function, add 'node' as argument to existing functions, defaulting it to device OF node. MFC after: 3 weeks Notes: svn path=/head/; revision=302528
* Add clk_get_by_ofw_node_index, which is like clk_get_by_ofw_index butJared McNeill2016-07-102-7/+17
| | | | | | | | | | operates on a specific OF node instead of the pass in device's OF node. Reviewed by: andrew, mmel Differential Revision: https://reviews.freebsd.org/D6957 Notes: svn path=/head/; revision=302523
* Rename gpiobus_map_pin() to gpiobus_acquire_pin(), to better reflect theIan Lepore2016-05-261-2/+2
| | | | | | | | fact that the caller is requesting exclusive use of the pin, and also to better match the inverse operation which is named gpiobus_release_pin(). Notes: svn path=/head/; revision=300750
* Use OF_prop_free instead of direct call to free(9)Oleksandr Tymoshenko2016-05-145-17/+17
| | | | | | | Reviewed by: mmel@ Notes: svn path=/head/; revision=299714
* Fix a format string when uint64_t is not unsigned long long by castingAndrew Turner2016-04-041-2/+2
| | | | | | | through uintmax_t. Notes: svn path=/head/; revision=297550
* Pass clkdev_if methods through to parent device by default.Jared McNeill2016-03-281-5/+53
| | | | | | | | | Reviewed by: mmel, adrian (mentor) Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D5750 Notes: svn path=/head/; revision=297350
* Do nothing if requested clk frequency is already correct.Alexander Kabaev2016-03-271-0/+4
| | | | | | | Reviewed by: mmel Notes: svn path=/head/; revision=297328
* Fix support for fixed factor clocks.Jared McNeill2016-03-231-4/+11
| | | | | | | | | | | | | | | - Use a different device description for fixed and fixed factor clocks. - Fix a bug where the "clock-div" property was stored in the "mult" field of the clock definition. - Get the fixed factor parent clock by index instead of by name, as a clock-names property is not required to be present here. Reviewed by: mmel, adrian (mentor) Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D5703 Notes: svn path=/head/; revision=297215
* clk_parse_ofw_out_names is supposed to return a list of indices when theJared McNeill2016-03-232-4/+4
| | | | | | | | | | | | clock-indices property is present, so change the "uint32_t *indices" parameter to "uint32_t **indices" to allow this. Reviewed by: mmel, adrian (mentor) Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D5702 Notes: svn path=/head/; revision=297214
* Return BUS_PROBE_GENERIC instead of 0 from ofw_clkbus_probe, givingJared McNeill2016-03-231-1/+1
| | | | | | | | | | | platform specific drivers a chance to override the generic driver. Reviewed by: mmel, adrian (mentor) Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D5701 Notes: svn path=/head/; revision=297213
* Add phy framework, a next part of new 'extended resources' family ofMichal Meloun2016-03-153-0/+382
| | | | | | | | | | support frameworks (i.e. clk/regulators/tsensors/fuses...). It provides simple unified consumers interface for manipulations with phy (USB/SATA/PCIe) resources. Notes: svn path=/head/; revision=296907
* Add regulator framework, a next part of new 'extended resources' family ofMichal Meloun2016-03-157-0/+1838
| | | | | | | | | | | support frameworks(i.e. clk/reset/phy/tsensors/fuses...). The framework is still far from perfect and probably doesn't have stable interface yet, but we want to start testing it on more real boards and different architectures. Notes: svn path=/head/; revision=296906