|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 K* v. o- C8 D# |6 t
#include <linux/init.h>5 E0 w' r, l, _) y
#include <linux/module.h>
- z/ l7 q% N' ? K6 C* p#include <linux/kernel.h>
2 ~/ a' s0 T$ o$ O7 h#include <linux/types.h>/ W& _5 z: Q! [8 C' B1 u8 K0 Q
#include <linux/gpio.h>
{5 e1 E$ V) _0 {. R) I#include <linux/leds.h>" W/ i; h( g4 }% E. a) K6 Z
#include <linux/platform_device.h>
& o2 ^$ K1 y) W, D
! j/ f( l( D6 z4 w8 s. d7 I. t" C#include <asm/mach-types.h>
1 x$ O5 K" \4 B _#include <asm/mach/arch.h>
3 L2 |# Q1 F4 _% X#include <mach/da8xx.h>
! q' g" {! [ i) l, [) g `#include <mach/mux.h>& c- _/ W$ \6 \0 Y0 R
: N/ e/ y1 }- }, x& x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), F' ?& I5 n4 e' w4 a! s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- w# y T- @2 D8 m V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& `- X" K- y& s b. z2 k0 t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) ~# A( I4 j2 M; U
1 {' B6 s; b7 Y% z% c
/* assign the tl som board LED-GPIOs*/, i: e! o6 c- X% j8 y
static const short da850_evm_tl_user_led_pins[] = {8 ]) Y y% A* u& a
/* These pins are definition at <mach/mux.h> file */
% ~2 U, v/ b, B& b1 _: n$ Z# c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# f( Y2 n, k% [% z -1
1 ]& B6 _9 l; M5 |# o};
/ }1 o+ }9 _7 R5 ]* D
6 y s" E6 b D( j. Qstatic struct gpio_led da850_evm_tl_leds[] = {
9 z# Q5 } |& _2 {2 z+ \6 c {5 y7 y; [2 I5 {; P3 ~" J x5 t6 ]- ?& U
.active_low = 0,) i0 u) t( D3 k$ [; p4 x* [8 U
.gpio = DA850_USER_LED0,3 Y+ D$ f. u7 A6 p1 b- Q
.name = "user_led0",6 s5 R( p# H! w/ o) J( H( r
.default_trigger = "default-on", B4 x" [' m6 h, G3 s6 A
},7 a& A2 Q& S1 V9 E4 a) A
{. C# v8 p8 y( n K
.active_low = 0,$ g/ n/ Y: ~2 D
.gpio = DA850_USER_LED1,
$ t' `2 x v9 ? .name = "user_led1",+ [' ^" ^7 k* @4 T. x4 i f
.default_trigger = "default-on",
& n/ G9 i8 m3 x3 r0 q/ i. `. e X3 | },! j& ~- V4 M5 S& \# |. M, P) F
{) g% I9 i6 m! S/ _
.active_low = 0,
/ n, ` U: N* F* m- ? .gpio = DA850_USER_LED2,
% n9 x6 N0 x2 P0 S3 M .name = "user_led2",
' r! B5 ^' f% X6 g5 p- u .default_trigger = "default-on",
- G) F" U3 L! K, d' q },
1 t5 `. h$ z& {; r {
* a# _5 }) E1 ~4 n .active_low = 0,
; X" } N8 D, e! W9 c1 L7 c .gpio = DA850_USER_LED3,
- W( D M9 M7 a3 s- \* F" | .name = "user_led3",
! O- B: w1 [/ F+ _/ s) I; \6 V .default_trigger = "default-on",+ o8 d6 ]& A# U: z% ~
},
+ Z# Q2 {0 h3 Z7 a- \$ h& v- g1 k};
2 x% N9 V' t8 a* [/ v
2 O9 \4 ?7 d) v- t' W j) w4 F: _7 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 q' L Y2 e* J c
.leds = da850_evm_tl_leds,
9 Q4 a: U8 F/ X1 J2 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 T( f6 N0 \5 j/ A. @0 i+ _* @+ s9 s8 ~};
9 r( }( N$ {2 O# N) J% S
8 s. G ]3 }7 `( N% C5 Pstatic void led_dev_release(struct device *dev)0 }1 \8 s% P3 K4 E4 O
{+ h1 p: c o0 a$ ]6 V! H' A- f
};% |* q$ E" u A" a( \! H7 u4 L
4 R- Q! \# N- _' \9 vstatic struct platform_device da850_evm_tl_leds_device = {" f, l) b6 F3 K* M) g3 C! q- Z( j
.name = "leds-gpio",
0 j: J! @8 z% C .id = 1,% s1 S1 M* s/ x1 N4 \; s. z, e! _
.dev = {
) p4 i1 E$ e( [2 \6 i9 k# T( I5 x6 i .platform_data = &da850_evm_tl_leds_pdata,
* N* I/ ]+ X: u0 F+ e .release = led_dev_release,
9 A0 }, _$ }# R' o @9 j% I, L }
/ z( w2 W) [ u; z$ }# ]) p7 k2 z: y* j};
' q8 d% c: M8 Z& R5 @
# n2 m# ^# [( y5 d9 cstatic int __init led_platform_init(void)
( `- `8 T9 e4 D, s. r- E{
0 j& |- D1 U/ @9 e* v int ret;. f) p7 q& H* U" a) u& A( ^# Z
#if 0
+ G; R5 t, l# c2 U. \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 i% G2 Y. ]6 k$ ? if (ret)
. _, Y& I0 |2 \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& q; }, O c, [2 ?$ ^7 N3 N. Y "%d\n", ret);
: r4 `1 S+ z: H) S R#endif
3 P) ^8 I. w2 U# s# M( h1 E3 y7 f4 w- m ret = platform_device_register(&da850_evm_tl_leds_device);
/ s$ u& m' t; r if (ret)
) S; i; t9 m' _* A pr_warning("Could not register som GPIO expander LEDS");
! ^* d1 s; M! r# l5 v2 F else% c* ^+ J# j& [ T2 H
printk(KERN_INFO "LED register sucessful!\n");
/ i1 t9 P& c: l" h# w9 L6 z) z5 l& H/ v1 M9 D7 U- m5 x
return ret;3 Q# K5 U% r/ _& \( g& w/ c B& [' q
}
0 R2 M- W" C: `1 p4 D- U$ x' w; |. x: Q
static void __exit led_platform_exit(void)
; s \6 a/ R& {. f+ ~& x8 B{
7 ]! Y2 w1 f& T5 {& @* r/ m platform_device_unregister(&da850_evm_tl_leds_device);
. \* c0 i" ]1 |$ a5 E2 ^1 P, ]) R& L( S. f
printk(KERN_INFO "LED unregister!\n");0 j' [8 a( Y+ h/ C& _
}
7 c; r& X+ {) o3 {+ _
( M/ S- Q/ S7 ^ @8 s, K v1 Dmodule_init(led_platform_init);
7 L3 D; X8 N5 \1 F7 f' y, o* jmodule_exit(led_platform_exit);3 y! T2 w( E( |# ~: d
/ ` Y* `% n6 T. Y
MODULE_DESCRIPTION("Led platform driver");
# ^% `: ?" S: ?& b& C& E$ D; ]MODULE_AUTHOR("Tronlong");
. n/ L- A5 C% `. [MODULE_LICENSE("GPL");
1 y& |/ `) u6 P" D: b; |& \' c; Q3 o0 h/ |! V
|
|