|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& R" o, I( r9 a3 t
#include <linux/init.h>
' D8 F' U8 l& H4 {#include <linux/module.h>
3 ^6 H7 j) W0 h#include <linux/kernel.h>
+ u8 O+ q+ J3 V" S0 i' s#include <linux/types.h>
" x' k; {& m& u* i8 I8 W#include <linux/gpio.h>
6 z5 V; y/ q8 \6 q#include <linux/leds.h>+ m' _& }2 v- `( ?) _& H
#include <linux/platform_device.h> r Z) R# O1 E" C( _, g- v
$ `( w t3 f# w0 @ k: x. i; [#include <asm/mach-types.h>5 c/ x ~) s" k
#include <asm/mach/arch.h>
) E6 G0 J8 P( [* e a' u$ ]- d#include <mach/da8xx.h>
9 C/ Q3 ~2 B% P% V#include <mach/mux.h>
4 r5 f, ^) ~( _! D& {
# t& t4 r6 |9 k' I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* @. P5 x, i- \) W2 _- k( f& R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 `, _ N6 k |: \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), b9 v" N; Y& r! b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* A; M- {/ J G: M& N$ A& S6 N
: E9 ]$ P2 H# h/* assign the tl som board LED-GPIOs*/
% D. c/ Y7 V, p( S! }, m3 V0 Qstatic const short da850_evm_tl_user_led_pins[] = {8 |4 I4 y) D i5 l
/* These pins are definition at <mach/mux.h> file */. |4 |5 m" H3 \5 ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: ^% {6 }7 Y6 t8 J) |: ]
-1/ V3 D3 E# S3 E
};
9 r4 j' ~2 v4 o5 J- i: x8 V
: S( n8 g9 S3 ^, d, Ustatic struct gpio_led da850_evm_tl_leds[] = {. h4 x# J7 ?- V: m S$ S
{- {! O# K, n$ _5 a3 W0 ]
.active_low = 0,( O# F/ r- i) a0 J- _
.gpio = DA850_USER_LED0,2 ~+ \ m! V T0 n g8 G w* V1 G
.name = "user_led0",
' k3 V8 Q8 m) @( M$ Q% E8 U/ } .default_trigger = "default-on",: K" V; B1 x4 s; U# \% L: a
},
$ c& \& ^( f# d b* a+ |% Z; Y8 w6 c {$ `& [5 |% V g7 P" q3 R4 Q( q
.active_low = 0,
8 y& R+ s$ W; ^ .gpio = DA850_USER_LED1,# K" A* g' X% ?1 |: X% V p
.name = "user_led1",
4 k) D4 a( p& Y+ n8 f4 h. o .default_trigger = "default-on",
# k7 j6 @' _: r2 p },' e: t5 a& p9 G! N; u
{- k! E: j- {) w
.active_low = 0,
) i4 v" P( `2 n .gpio = DA850_USER_LED2,
4 H+ M: V' l1 d% m6 W+ N .name = "user_led2",/ E) O, i6 Z3 y; f7 q$ L |. \8 Y
.default_trigger = "default-on",
$ N1 u" W" Z) T9 [7 N- A$ o% U },/ |3 L6 c; H+ _$ k* |9 `9 v T
{
" N! R5 h# |* u$ O: e' v .active_low = 0,
! `- e$ L# f/ ?# q% q) E4 v .gpio = DA850_USER_LED3,, f6 \ Y' e! X, `, R0 K
.name = "user_led3",6 n: J# Y+ {- k+ T
.default_trigger = "default-on",
6 ^0 T. h1 W( z7 c, @8 Y },
: z! r8 h" J* l0 I7 k: a};% I a6 o7 F" B- |( `4 b+ D
- \1 z: x# ^ z' D% Y! U, v* U1 f3 N$ Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ I4 w0 C5 F5 F3 x- i. [" u. P .leds = da850_evm_tl_leds,7 E0 j5 ]) w" G5 h; W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& A) A/ {8 b: l- R( {4 A- n
};/ l9 c- S. H( D( ~; g: L. S5 X
) x3 {. a! d* G9 }# O
static void led_dev_release(struct device *dev)
; E# t, r$ T3 B' L0 [{) \: m: M4 C3 Y8 ?% J
};
1 }1 O3 V$ }0 ]" m
; b+ w4 Z; O7 X/ \1 }, kstatic struct platform_device da850_evm_tl_leds_device = {
* I0 Q3 m; [1 o; c. J .name = "leds-gpio",- `; Q3 W5 ]8 Y+ a4 l. E
.id = 1,
8 l+ d: J* ~3 c4 i5 a6 S- H# m .dev = {
. j$ L5 W; `% }$ Z .platform_data = &da850_evm_tl_leds_pdata,( d5 ?" g$ M. b0 Y- s# f# F
.release = led_dev_release,
) Q5 k1 h; \6 J }. r9 c+ L, v# ]( T$ q
};
?" `1 c# G' p0 _. }+ w
' q6 g. C8 }: k1 D5 O/ Y0 }static int __init led_platform_init(void). A* q/ m( S, |# t
{3 l1 K) F, Z' ]: {1 P9 B/ c
int ret;
* i& \# p, ]* A& ^. w9 j- P- M#if 02 J7 {: E G8 c: Q k" z/ R% c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" @4 @; w8 T4 Z' A
if (ret)/ }8 M! s, F1 z4 d1 ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 j' t6 g3 P: h& P4 A
"%d\n", ret);8 r- T- d8 \$ H+ I6 U
#endif
- e q, V% G+ b7 x ret = platform_device_register(&da850_evm_tl_leds_device);5 |6 ?1 {+ t$ W9 Y/ Q. N4 S/ l
if (ret)3 c$ {( H& W7 n
pr_warning("Could not register som GPIO expander LEDS");
v: s2 f" M1 y else
5 F: v6 H# j8 E$ j6 Y- R& q! q printk(KERN_INFO "LED register sucessful!\n");3 H( A4 u, `' v; W
! c G/ H( ]& G9 y5 ] M return ret;0 D2 K$ l% y- N5 E, p" t+ |" ?0 D8 q
}! ^* n7 `- L, F/ R
# X2 C) u5 h1 r# w; K5 ^static void __exit led_platform_exit(void)) J. K J6 T' P) u' T5 Y/ q5 i
{4 J& t% ]( r' O$ i& E3 \# A
platform_device_unregister(&da850_evm_tl_leds_device);$ _! A) Q- {+ m: K% o
4 o) n7 B8 \# ?+ M% ^! C
printk(KERN_INFO "LED unregister!\n");4 Y$ p' ]5 I. f: c
}% ~* x0 i1 ]2 |1 o2 j& b9 `
) v6 e5 E# R1 T) Tmodule_init(led_platform_init);
, x- r. L. c+ {& W2 h1 a! Wmodule_exit(led_platform_exit);# L1 z+ W5 a% X: u$ B" D
1 {7 k* m" n% J8 ?7 V: R: D& N, ^
MODULE_DESCRIPTION("Led platform driver");* V1 H( I, h$ M3 L( x9 _
MODULE_AUTHOR("Tronlong");
+ t: X$ W. R" kMODULE_LICENSE("GPL");
; F5 r4 e4 T, ~2 W; \. ^ F% W$ _6 s0 I% `
|
|