aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/extres
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement support for (soft)linked clocks.Michal Meloun2019-11-084-10/+255
| | | | | | | | | | | This kind of clock nodes represent temporary placeholder for clocks defined later in boot process. Also, these are necessary to break circular dependencies occasionally occurring in complex clock graphs. MFC after: 3 weeks Notes: svn path=/head/; revision=354554
* regulator: Add regulator_check_voltage functionEmmanuel Vadot2019-11-064-0/+42
| | | | | | | | | | | | | | This function will call the regnode_check_voltage method for a given regulator and check if the desired voltage in reachable by it. Also adds a default method that check the std_param and which should be enough for most regulators and add it as the method for axp* rk805 and fixed regulators. Reviewed by: mmel MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D22260 Notes: svn path=/head/; revision=354396
* regulator: Add a regnode_set_constraint functionEmmanuel Vadot2019-10-232-0/+70
| | | | | | | | | | | | | | | | | | | This method check that boot_on or always_on is set to 1 and if it is it will try to enable the regulator. The binding docs aren't clear on what to do but Linux enable the regulator if any of those properties is set so we want to do the same. The function first check the status to see if the regulator is already enabled it then get the voltage to check if it is in a acceptable range and then enables it. This will be either called from the regnode_init method (if it's needed by the platform) or by a SYSINIT at SI_SUB_LAST Reviewed by: mmel MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22106 Notes: svn path=/head/; revision=353919
* regulator: Add a regnode_method_initEmmanuel Vadot2019-10-231-0/+9
| | | | | | | | | | This is a default init method for regulator that don't really need one. MFC after: 1 week Notes: svn path=/head/; revision=353917
* Add method for getting of syscon handle from parent device.Michal Meloun2019-08-182-0/+20
| | | | | | | | | | | | If simple multifuction device also provides syscon interface, its childern should be able to consume it. Due to this: - declare coresponding method in syscon interface - implement it in simple multifunction device driver MFC after: 1 week Notes: svn path=/head/; revision=351184
* allwinner: Add a new clock aw_clk_mEmmanuel Vadot2019-08-101-0/+1
| | | | | | | | | | | | | | | | | | | | | We used the aw_clk_nm clock for clock with only one divider factor and used a fake multiplier factor. This cannot work properly as we end up writing the "fake" factor to the register (and so always set the LSB to 1). Create a new clock for those. The reason for not using the clk_div clock is because those clocks are a bit special. Since they are (almost) all related to video we also need to set the parent clock (the main PLL) to a frequency that they can support. As the main PLL have some minimal frequency that they can support we need to be able to set the main PLL to a multiple of the desired frequency. Let say you want to have a 71Mhz pixel clock (typical for a 1280x800 display) and the main PLL cannot go under 192Mhz, you need to set it to 3 times the desired frequency and set the divider to 3 on the hdmi clock. So this also introduce the CLK_SET_ROUND_MULTIPLE flag that allow for this kind of scenario. Notes: svn path=/head/; revision=350844
* Extract eventfilter declarations to sys/_eventfilter.hConrad Meyer2019-05-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header pollution substantially. EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c files into appropriate headers (e.g., sys/proc.h, powernv/opal.h). As a side effect of reduced header pollution, many .c files and headers no longer contain needed definitions. The remainder of the patch addresses adding appropriate includes to fix those files. LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by sys/mutex.h since r326106 (but silently protected by header pollution prior to this change). No functional change (intended). Of course, any out of tree modules that relied on header pollution for sys/eventhandler.h, sys/lock.h, or sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped. Notes: svn path=/head/; revision=347984
* extres: Unify error codes for <foo>_get_by_ofw_property() methods.Michal Meloun2019-03-193-3/+3
| | | | | | | | | | | | Return: - ENOENT if requested property doesn't exist - ENODEV if producer device is not (yet) attached - ENXIO otherwise MFC after: 2 weeks Notes: svn path=/head/; revision=345295
* Properly define and declare phynode_topo_lock,Michal Meloun2019-01-272-2/+2
| | | | | | | | | | it should be single global variable. X-MFC with: r340845 Noticed by: phynode_topo_lock Notes: svn path=/head/; revision=343498
* extres: clk: Fix clk_set_assignedEmmanuel Vadot2018-11-291-4/+4
| | | | | | | | | | ofw_bus_parse_xref_list_get_length doesn't returns the number of elements, fix this. While here when setting the clock to the assigned freqeuncy, allow the clock driver to round down or up the frequency as sometimes the exact frequency cannot be obtain. Notes: svn path=/head/; revision=341254
* regulator_fixed: Do not disable fixed regulator at probeEmmanuel Vadot2018-11-261-8/+8
| | | | | | | | | | | | | | | If the regulator is unused it will be disabled by the regulator_shutdown sysinit. Tested on pinebook where the backlight is controlled by a fixed-regulator. The regulator doesn't have a regulator-boot-on param (I'm gonna upstream this) and so we disable it at probe. We later enable it but this cause the screen to go black. Linux doesn't disable regulator at boot (at least for fixed-regulator) so better match this to have the same UX. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D17978 Notes: svn path=/head/; revision=340989
* Derive PHY class to new one specialized for USB PHY functions.Emmanuel Vadot2018-11-235-50/+369
| | | | | | | Submitted by: mmel Notes: svn path=/head/; revision=340845
* 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