|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) Q' D; }! o# E' W7 ]- X
#include <linux/init.h>
! U# U, `2 X& T/ B7 ]8 ]#include <linux/module.h>1 g* g/ e2 P8 C# k4 R" ^) i
#include <linux/kernel.h>+ [5 U$ V3 W% x+ v# R
#include <linux/types.h>
( l8 w- D( i$ b5 S$ O#include <linux/gpio.h>) I# M- L: M, i1 e8 i
#include <linux/leds.h>
f: F e/ x$ M2 [#include <linux/platform_device.h>; X) F5 q7 K- ^8 E5 ]! l" d T
" F4 p$ a: N$ D#include <asm/mach-types.h>1 h4 E5 A, L! F
#include <asm/mach/arch.h>
( q% |. z/ P, ^1 S#include <mach/da8xx.h>2 b: }" a* l" H* X7 \
#include <mach/mux.h>
+ p* G! j3 r: P8 [" D. c1 a& H. R# x& K' P) F( g% A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& D2 h$ {# M$ u# M8 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ Z4 e" L8 m) E+ |' W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 o+ u4 F) P8 s* X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: f) B8 [% w/ Q$ e7 M3 h, k9 @& f0 x2 B. D8 W$ s& y
/* assign the tl som board LED-GPIOs*/
2 U, B$ V2 i, Q2 Y8 C$ `) Fstatic const short da850_evm_tl_user_led_pins[] = {
$ _! j3 z7 C( ? W4 B /* These pins are definition at <mach/mux.h> file */
# M4 Y# _% e; C, c) D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) b1 p" V. p/ [1 A" E6 F+ {
-1
: s4 [( K0 `1 L1 _};! M4 R# t$ e) o
k$ I( I# x# p$ Y5 |" Ustatic struct gpio_led da850_evm_tl_leds[] = {. q9 E$ p0 g$ C$ n* K9 U% \
{
* W6 \6 m! j4 ? } {) E% v9 U .active_low = 0,$ [. M# [5 R8 d3 Z2 _+ P9 T
.gpio = DA850_USER_LED0,( ?4 g9 k1 c2 W4 A# F; e+ `
.name = "user_led0",5 A# w0 J9 s. S. p
.default_trigger = "default-on",
& ~2 V# q3 b |, h- h7 V/ t4 D, X },
% Y! Z2 U& \- K' W u {2 _* H; l1 B% [5 O
.active_low = 0,6 d) b, u& B; f, e3 _6 K
.gpio = DA850_USER_LED1,- j# F, p0 @/ v7 [
.name = "user_led1",
" a! t! }* U( Y' J .default_trigger = "default-on",, C) s2 @" ]; A9 P" r) C) G
},
* G+ W. e4 j2 f# c {
- E8 i9 ~) ?) x7 ` .active_low = 0,
9 z5 a2 r9 o* v3 i% H' f& m .gpio = DA850_USER_LED2,
|8 B- u3 e* F! R .name = "user_led2",
) L- n$ N8 ~% R$ B2 ]- H2 A .default_trigger = "default-on",
, t$ M! \0 W/ s9 p+ O1 L, r2 q },: f# z1 d7 [& L9 m! Y
{. L) X9 [: a8 A' f. v2 S
.active_low = 0,5 v9 y, z# h5 [9 J' }% z6 |
.gpio = DA850_USER_LED3,
2 y ~6 ?, m6 p; ?% K! z+ f1 p9 U, | .name = "user_led3",. O v' o" o( V1 K6 e
.default_trigger = "default-on",
) e2 P& e, \9 u, Q7 k. U( b },* t# n# I' Z1 T
};
$ l- k9 i+ t3 b: S$ R1 i8 o% ~2 U' q% ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% t* f+ n5 l: s
.leds = da850_evm_tl_leds,
8 C% L; \: {) B _4 p2 u+ a .num_leds = ARRAY_SIZE(da850_evm_tl_leds), |$ ]& I* J* h4 J1 o: m' ]4 y* b
};
" q* j$ Z8 h; T# ?0 [0 D% x( s8 T& W
) V0 [- Y+ h& e2 z: [9 V' Y0 kstatic void led_dev_release(struct device *dev)
/ K: {* A3 h5 L ^5 I& j' o{
& G$ l1 S+ ]) ^3 s) ?};# ~' Q/ k, Z% L+ k" F
8 u. k0 i- q, Z; P( s/ w( rstatic struct platform_device da850_evm_tl_leds_device = {
2 M( |' _: T* s9 u" L% v, J3 j5 ~ .name = "leds-gpio",/ L5 v( Y9 W1 {6 T+ Y, e) V* J7 V
.id = 1,
* \7 @5 n4 N& ]7 Q2 i7 N! l .dev = {1 x6 {* f% t, i" @
.platform_data = &da850_evm_tl_leds_pdata,! q* f0 z' d) K" F
.release = led_dev_release,
6 [8 U4 Q, s# X4 ^% G }
0 h5 d6 ~( P. H( A! Z; C}; d. w7 ~1 v9 P' R4 l! ]
+ [5 X: c0 N2 P6 k2 L4 {( c/ B! d
static int __init led_platform_init(void)* a+ y( h( k" e$ s
{; K# z" N* A n4 J0 e
int ret;. w' C: ~" J/ x# A7 e) ]& g
#if 0( H/ \) [! f2 a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) @) s$ j0 O$ i; C3 |
if (ret)
% ?; ?, y- V, l5 A: E+ D1 N; r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# B* L K/ D J$ r% ?1 @1 M& R# @8 h, F "%d\n", ret);
! i- s$ J, I3 ]" m#endif2 q/ K# f/ m7 z7 u
ret = platform_device_register(&da850_evm_tl_leds_device);
5 x Y( d7 _$ M/ ?3 e# C if (ret)1 E' P9 w, S. i% H u5 I+ X: f; c
pr_warning("Could not register som GPIO expander LEDS");
# T; _* M% S W! y else
. l: ^0 y( i3 {9 K printk(KERN_INFO "LED register sucessful!\n");
$ a2 U* \3 z* [, e9 p( a. ^7 F @5 j) ^9 i
return ret;1 O) b# {' B% u9 Y/ {5 N
}: \/ K$ A8 |( U% a$ _8 l
. q/ E9 @7 u5 `! Y8 q( G, N
static void __exit led_platform_exit(void)
# t$ ^: l3 n. x{; w; _1 S' D8 D8 s f3 l
platform_device_unregister(&da850_evm_tl_leds_device);2 B8 M% g$ @. H1 S/ f) m9 c
7 w8 f* }- k& v" ^3 v: C printk(KERN_INFO "LED unregister!\n");
, g9 f& g- ~7 L" V$ Z% A% @}0 J3 I, h. W) j% ]
/ G& t9 o+ @/ u. `* _
module_init(led_platform_init); ]# Q X5 k9 u8 L8 p9 @
module_exit(led_platform_exit);; [& E/ a" y0 a
- B+ J" m/ @0 l8 o
MODULE_DESCRIPTION("Led platform driver");# y2 E2 m# Y5 E) Z, H) Y r
MODULE_AUTHOR("Tronlong");. F- E, M) W' W- H3 H; s+ U
MODULE_LICENSE("GPL");; x: K+ Y7 q/ a) ^4 x
9 X: W) Z; Q3 y$ t9 X- o, s |
|