Commit Graph

190 Commits

Author SHA1 Message Date
Nathan Whitehorn
a3550e73e4 Be a little more suspicious of thermal sensors, which can have single
crazy readings occasionally. One wild reading should not be enough to
trigger a shutdown, so instead wait for several concerning readings in
a row.

PR:		powerpc/180593
Submitted by:	Julio Merino
MFC after:	1 week
2013-10-25 03:55:52 +00:00
Nathan Whitehorn
17593f8612 Standards-conformance and code deduplication:
- Use bus reference phandles in place of FDT offsets as IRQ domain keys
- Unify the identical macio/fdt/mambo OpenPIC drivers into one
- Be more forgiving (following ePAPR) about what we need from the device
  tree to identify an OpenPIC
- Correctly map all IRQs into an interrupt domain
- Set IRQ_*_CONFORM for interrupts on an unknown PIC type instead of
  failing attachment for that device.
2013-10-22 14:07:57 +00:00
Andreas Tobler
965205eb66 Move the resource allocation from the ata_*_probe section to the ata_*_attach
section. This prevents a boot crash on nearly all iMacs and PowerMacs/Books.

The allocation in the probe section was working before because ata_probe was
returning 0 which did not invoke a second DEVICE_PROBE. Now it returns
a BUS_PROBE_DEFAULT which can invoke a second DEVICE_PROBE which results in
a "failed to reserve resource" exit.

PR:	powerpc/182978
Discussed with:	grehan@
MFC after:	1 Week
2013-10-15 18:59:32 +00:00
Nathan Whitehorn
9f70672718 Rework handling of ofw_quiesce(), making it the responsibility of the
platform modules. Whether to call this function or not is highly machine
dependent: on some systems, it is required, while on others it breaks
everything. Platform modules are in a better position to figure this
out. This is required for POWER hypervisor SCSI to work correctly. There
are no functional changes on Powermac systems.

Approved by:	re (kib)
2013-09-27 13:12:47 +00:00
Nathan Whitehorn
5d46492ddc Attach only on hardware that is actually supported as opposed to hardware
that seems like it has some of the problems we might want.

Approved by:	re (kib)
2013-09-09 12:54:08 +00:00
Justin Hibbits
427467b32e Only add the backlight device if it actually exists in OF.
MFC after:	1 week
2013-08-31 16:31:48 +00:00
Andreas Tobler
b1397508be Return EIO iso -1, the kiic_transfer has an signed return.
Submitted by: Luiz Otavio O Souza <loos.br AT gmail.com>
2013-08-23 20:39:41 +00:00
Justin Hibbits
84cd55bb02 Add the macio attachment for wi(4). Partially obtained from NetBSD.
Reviewed by:	adrian
Obtained from:	NetBSD (partially)
2013-07-31 01:13:29 +00:00
Nathan Whitehorn
7f3d2746af Only check fan type once. Not only is continuously rechecking pointless, a
single random failure can reprogram what control mechanism we try to use.

MFC after:	2 weeks
2013-05-05 22:42:10 +00:00
Marius Strobl
d2ce15bd43 - With the demise of !ATA_CAM, ATA_STATIC_ID is the only ata(4) related
option left but actually consumed by ada(4), so move it to opt_ada.h
  and get rid of opt_ata.h.
- Fix stand-alone build of atacore(4) by adding opt_cam.h.
- Use __FBSDID.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.
2013-04-06 19:12:49 +00:00
Rui Paulo
eaba9848dd Introduce PLATFORMMETHOD_END and use it. 2013-02-13 02:21:45 +00:00
Nathan Whitehorn
feb8a1f5f5 Work around broken device tree on last-generation PowerPC iMacs
(PowerMac12,1), which have a mac-io MPIC cell that indifies itself
as the root PIC despite the actual root PIC being on the northbridge.
No CPC945 systems have a mac-io PIC that does anything so just don't
attach on CPC945 (U4) systems.

MFC after:	3 days
2012-10-29 14:27:28 +00:00
Justin Hibbits
1342232fe1 phandle_t is unsigned, and OF_finddevice() returns (phandle_t)(-1) on
failure, so check for that instead of 0.

While here, provide a better description for ATI backlight driver.

Reported by:	jchandra@
MFC after:	3 days
2012-08-21 23:55:29 +00:00
Justin Hibbits
d0ec68d41c Add backlight support for nVidia-based PowerBooks/iBooks/iMacs.
Approved by:	nwhitehorn (mentor)
MFC after:	9.1-RELEASE
2012-08-04 03:05:01 +00:00
Rui Paulo
9e731915eb Remove bogus __unused attribute from hrowpic_eoi(). 2012-07-01 19:07:45 +00:00
Andreas Tobler
43cbf1a696 Provide a fix for certain PowerMacs where the U3 i2c lacks the interrupt
info.

Tested by:	Robert Hish
MFC after:	1 week
2012-03-19 18:03:20 +00:00
Andreas Tobler
0cb9915474 Add support for PWM controlled fans. I found these fans on my PowerMac9,1.
These fans are not located under the same node as the the RPM controlled ones,
So I had to adapt the current source to parse and fill the properties correctly.
To control the fans we can set the PWM ratio via sysctl between 20 and 100%.

Tested by:	nwhitehorn
MFC after:	3 weeks
2012-03-04 08:43:33 +00:00
Justin Hibbits
3cc28bd9bf Add backlight control to ATI-graphics PowerBooks and iBooks.
Approved by:	nwhitehorn (mentor)
MFC after:	1 week
2012-02-26 13:45:25 +00:00
Nathan Whitehorn
bc85eb26b3 Improve error handling in smusat(4).
MFC after:	4 days
2012-02-15 16:59:24 +00:00
Nathan Whitehorn
761d31e8bf Compatibility with IBM firmware. 2012-02-04 23:25:18 +00:00
Nathan Whitehorn
64f4cd756e Miffed r230993 due to a one-character typo while reviewing the patch. 2012-02-04 20:04:35 +00:00
Nathan Whitehorn
9a35e64eb4 Unify OF PCI infrastructure, including changing from parsing the device
tree based on heuristics to parsing it based on the spec. This should also
lay the foundation for NEW_PCIB on PowerPC.

MFC after:	3 months
2012-02-04 19:54:13 +00:00
Nathan Whitehorn
8bab0d80ca Prevent an error resulting from signed/unsigned comparison on systems
that do not comply with the OF spec.

Submitted by:	Anders Gavare
MFC after:	1 week
2012-01-20 22:24:39 +00:00
Justin Hibbits
82b6bd7d0e Add PWM monitoring sysctl to G4 MDD (Windtunnel) fan driver. While there, clean
up some style nits.

Approved by:	nwhitehorn (mentor)
MFC after:	3 days
2012-01-12 22:21:20 +00:00
Justin Hibbits
23ab37cb82 Fix style(9) issues from r228270.
Approved by:	nwhitehorn (mentor)
2011-12-05 14:13:21 +00:00
Justin Hibbits
6431ede397 Add a devd notification for closing/opening the lid on PowerBooks and iBooks.
Approved by:	nwhitehorn (mentor)
2011-12-05 00:12:10 +00:00
Jayachandran C.
07042bef45 Fix OF_finddevice error return value in case of FDT.
According to the open firmware standard, finddevice call has to return
a phandle with value of -1 in case of error.

This commit is to:
- Fix the FDT implementation of this interface (ofw_fdt_finddevice) to
  return (phandle_t)-1 in case of error, instead of 0 as it does now.
- Fix up the callers of OF_finddevice() to compare the return value with
  -1 instead of 0 to check for errors.
- Since phandle_t is unsigned, the return value of OF_finddevice should
  be checked with '== -1' rather than '<= 0' or '> 0', fix up these cases
  as well.

Reported by:	nwhitehorn

Reviewed by:	raj
Approved by:	raj, nwhitehorn
2011-12-02 15:24:39 +00:00
Marius Strobl
4b7ec27007 - There's no need to overwrite the default device method with the default
one. Interestingly, these are actually the default for quite some time
  (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9)
  since r52045) but even recently added device drivers do this unnecessarily.
  Discussed with: jhb, marcel
- While at it, use DEVMETHOD_END.
  Discussed with: jhb
- Also while at it, use __FBSDID.
2011-11-22 21:28:20 +00:00
Ed Schouten
d745c852be Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.
This means that their use is restricted to a single C file.
2011-11-07 06:44:47 +00:00
Nathan Whitehorn
02d9c7407f Fix an error that could cause sysctl -a to enter an infinite loop in the
event of a broken or busy fan due to returning incorrect error codes from
the FCU sysctl handler.

Reported by:	Path Mather <paul at gromit dot dlib dot vt dot edu>1
Approved by:	re (kib)
2011-07-30 00:52:13 +00:00
Nathan Whitehorn
373506f71d Turn the minimum PWM fan speed down to 30 from 40. It turns out the burning
smell that caused me to turn this up was due to a failed fan burning, not
a CPU (plus a healthy dose of paranoia).

Submitted by:	Paul Mather <paul at gromit dot dlib dot vt dot edu>
2011-06-26 00:49:17 +00:00
Andreas Tobler
03c6aeca84 Add new fan controller driver for the G4 MDD PowerMac. Submitted and tested
by Justin Hibbits.

Approved by:	nwhitehorn (mentor)
2011-06-04 15:17:35 +00:00
Andreas Tobler
564a091bd2 - Improve error handling.
- Add retry loops for the i2c read/write functions.

Approved by:	nwhitehorn (mentor)
2011-06-04 09:25:59 +00:00
Andreas Tobler
7736fb1874 - Introduce a define for ZERO_C_TO_K.
- Fix the printing of the temperature when we exceed the critical value.

Approved by:	nwhitehorn (mentor)
2011-06-03 20:43:12 +00:00
Nathan Whitehorn
9d2a3635c1 Use kproc_exit() instead of returning from the management function on
systems with no manageable thermal control devices.
2011-05-29 22:37:23 +00:00
Nathan Whitehorn
d015abb774 Add some error handling here: if a sensor returns an error code (a negative
Kelvin temperature, which is impossible except for some contrived magnetic
spin systems), use the previous measurement from that sensor instead of
corrupting everything and randomly changing the fans or shutting off the
machine.
2011-05-29 20:46:53 +00:00
Nathan Whitehorn
d54e775e1e Add the next digit of precision to temperatures, which I missed when
converting the reporting format from degrees C to 0.1 degree K.
2011-05-29 20:04:02 +00:00
Nathan Whitehorn
cbfd4d0cbc Don't put negative values into the averages. 2011-05-29 19:53:11 +00:00
Nathan Whitehorn
815d7d92c1 Update the I2C-based temperature/fan drivers to connect to the Powermac
thermal control module. This provides automatic fan management on all G5
PowerMacs and Xserves.
2011-05-29 18:35:57 +00:00
Nathan Whitehorn
66e2bfe830 Adapt smusat(4) to use powermac_thermal. This provides automatic fan
management on dual- and quad-core Powermac G5s, and the last G5 iMacs.
2011-05-28 22:11:22 +00:00
Nathan Whitehorn
ad84e440a6 Require an error instead of a timeout to decide the new-style fan
commands won't work. This prevents a busy system from making smu(4)
suddenly decide its fans use the old-style command set.

MFC after:	3 days
2011-05-28 21:54:18 +00:00
Nathan Whitehorn
84d7767618 Factor out the SMU fan management code into a new module (powermac_thermal)
that will connect all of the various sensors and fan control modules on
Apple hardware with software-controlled fans (e.g. all G5 systems).

MFC after:	1 month
2011-05-28 21:13:22 +00:00
Nathan Whitehorn
cc734417b3 Do not use Open Firmware to open the device and instead program its start
on our own. This prevents hangs at boot when using a bm(4) NIC where the
cable is not plugged in at boot time.

Obtained from:	NetBSD
MFC after:	1 week
2011-05-06 03:26:24 +00:00
Nathan Whitehorn
f4338dac9f Don't sleep while setting the clock. This can cause panics when
periodic_resettodr() calls CLOCK_SETTIME() and smu tries to sleep while
running from a callout.

Reported by:	Torfinn Ingolfsen
2011-03-13 21:23:25 +00:00
Marcel Moolenaar
607ebaaf0c Rename INTR_VEC to MAP_IRQ. From the OFW or FDT we obtain a
PIC handle with interrupt pin. This we map to the resource
called SYS_RES_IRQ.
2011-02-02 05:58:51 +00:00
Marcel Moolenaar
6d2d7b8c0d Fix the interrupt code, broken 7 months ago. The interrupt framework
already supported nested PICs, but was limited to having a nested
AT-PIC only. With G5 support the need for nested OpenPIC controllers
needed to be added. This was done the wrong way and broke the MPC8555
eval system in the process.

OFW, as well as FDT, describe the interrupt routing in terms of a
controller and an interrupt pin on it. This needs to be mapped to a
flat and global resource: the IRQ. The IRQ is the same as the PCI
intline and as such needs to be representable in 8 bits. Secondly,
ISA support pretty much dictates that IRQ 0-15 should be reserved
for ISA interrupts, because of the internal workins of south bridges.
Both were broken.

This change reverts revision 209298 for a big part and re-implements
it simpler. In particular:
o   The id() method of the PIC I/F is removed again. It's not needed.
o   The openpic_attach() function has been changed to take the OFW
    or FDT phandle of the controller as a second argument. All bus
    attachments that previously used openpic_attach() as the attach
    method of the device I/F now implement as bus-specific method
    and pass the phandle_t to the renamed openpic_attach().
o   Change powerpc_register_pic() to take a few more arguments. In
    particular:
    -   Pass the number of IPIs specificly. The number of IRQs carved
	out for a PIC is the sum of the number of int. pins and IPIs.
    -   Pass a flag indicating whether the PIC is an AT-PIC or not.
	This tells the interrupt framework whether to assign IRQ 0-15
	or some other range.
o   Until we implement proper multi-pass bus enumeration, we have to
    handle the case where we need to map from PIC+pin to IRQ *before*
    the PIC gets registered. This is done in a similar way as before,
    but rather than carving out 256 IRQs per PIC, we carve out 128
    IRQs (124 pins + 4 IPIs). This is supposed to handle the G5 case,
    but should really be fixed properly using multiple passes.
o   Have the interrupt framework set root_pic in most cases and not
    put that burden in PIC drivers (for the most part).
o   Remove powerpc_ign_lookup() and replace it with powerpc_get_irq().
    Remove IGN_SHIFT, INTR_INTLINE and INTR_IGN.

Related to the above, fix the Freescale PCI controller driver, broken
by the FDT code. Besides not attaching properly, bus numbers were
assigned improperly and enumeration was broken in general. This
prevented the AT PIC from being discovered and interrupt routing to
work properly. Consequently, the ata(4) controller stopped functioning.

Fix the driver, and FDT PCI support, enough to get the MPC8555CDS
going again. The FDT PCI code needs a whole lot more work.

No breakages are expected, but lackiong G5 hardware, it's possible
that there are unpleasant side-effects. At least MPC85xx support is
back to where it was 7 months ago -- it's amazing how badly support
can be broken in just 7 months...

Sponsored by: Juniper Networks
2011-01-29 20:58:38 +00:00
Nathan Whitehorn
a0a3479c06 Disable ATAPI DMA unconditionally on Apple Kauai ATA controllers, like it
is on the MacIO ones. It appears to be unreliable on all DBDMA-based
controllers for unknown reasons, which should be figured out eventually.

Tested by:	Torfinn Ingolfsen
MFC after:	1 week
2011-01-23 17:20:11 +00:00
Andreas Tobler
639d24ce02 Remove unused variables. Spotted by a cppcheck
(devel/cppcheck, http://sourceforge.net/projects/cppcheck) run.

Approved by: nwhitehorn (mentor)
2011-01-20 20:23:03 +00:00
Andreas Tobler
d328763f19 Correct parsing of the grackle and uninorthpci ranges property.
Approved by: nwhitehorn (mentor)
2011-01-20 20:22:19 +00:00
Nathan Whitehorn
1161b88d4a Correct parsing of the cpcht ranges property.
Submitted by:	andreast
MFC after:	2 weeks
2011-01-20 15:02:51 +00:00