Page MenuHomeFreeBSD

Add GPIO driver for Nuvoton NCT5104D
ClosedPublic

Authored by daniel_dewyatt.com on Feb 22 2016, 3:48 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 3:25 PM
Unknown Object (File)
Sat, Apr 27, 11:14 AM
Unknown Object (File)
Apr 10 2024, 3:11 AM
Unknown Object (File)
Mar 23 2024, 2:16 AM
Unknown Object (File)
Mar 18 2024, 5:53 AM
Unknown Object (File)
Mar 18 2024, 5:53 AM
Unknown Object (File)
Mar 18 2024, 5:49 AM
Unknown Object (File)
Mar 18 2024, 5:49 AM

Details

Summary

This is a patch to add support for the GPIO functionality of the Nuvoton NCT5104D.
Tested on my PC Engines APU1C4 @ rev 297048.

Driver in action (youtube)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

daniel_dewyatt.com retitled this revision from to Add GPIO driver for Nuvoton NCT5104D.
daniel_dewyatt.com updated this object.
daniel_dewyatt.com edited the test plan for this revision. (Show Details)
daniel_dewyatt.com set the repository for this revision to rS FreeBSD src repository - subversion.
adrian added a reviewer: adrian.
adrian added a subscriber: adrian.

Hi!

Only thing missing are the bus barrier operations (which are noops on intel hardware, but still.)

Other than that, great!

This revision is now accepted and ready to land.Feb 22 2016, 4:36 AM
daniel_dewyatt.com updated this object.
daniel_dewyatt.com edited edge metadata.

Thank you for the feedback!
I was able to look at this today and added memory barriers and fixed a couple of silly mistakes.

Let me know if there's anything else I can do to get this committed.

This revision now requires review to proceed.Mar 20 2016, 3:26 AM

ok! one more little thing before I'll commit it.

You've got some locking in there, which is great. I'd like to see lock assertions in the places where you go and fiddle with the hardware.

So, read pin, write pin, pin is inverted, etc.

That way you can be absolutely sure that you've got the right lock held when you access the hardware.

Other than that, this works for you and it looks great, so let's get it in there. :-)

sys/dev/nctgpio/nctgpio.c
24 ↗(On Diff #14448)

Need a blank line and a $FreeBSD$ tag so it gets expanded. :p

53 ↗(On Diff #14448)

Normally I'd put the hardware definitions in a xxxreg.h file, but for something this small it's likely not worthwhile. We can always break it out later!

94 ↗(On Diff #14448)

And normally the struct and defines below would go into xxxxvar.h - but again, it's such a simple driver that it's not really worthwhile and not a commit blocker. :)

104 ↗(On Diff #14448)

Add a GPIO_LOCK_ASSERT( ) and GPIO_UNLOCK_ASSERT(). (see general comments.)

loos added a reviewer: loos.
This revision is now accepted and ready to land.Mar 20 2016, 5:03 AM
daniel_dewyatt.com updated this object.
daniel_dewyatt.com edited edge metadata.

Added locked/unlocked assertions and init/destroy macros. Added $FreeBSD$ tag.

There are only 4 functions that do direct IO with the device, so I added assertions there to ensure the lock is held. It did require initializing/destroying the mutex in a second location in the code, but still seems better than the alternative of trying to add the assertion to every path of execution leading to the 4 functions.

Tested and working: https://www.youtube.com/watch?v=a1vpRa7-pQY

This revision now requires review to proceed.Mar 23 2016, 6:12 AM
adrian edited edge metadata.

okay, I'll commit this today!

Thanks!

-a

This revision is now accepted and ready to land.Mar 30 2016, 5:59 PM
This revision was automatically updated to reflect the committed changes.