|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# m" Z9 |$ ^9 u* \3 }, E. K#include <linux/init.h>
6 M; e$ G5 ^8 T' x( W( c#include <linux/module.h>* ?" R; O- b/ }7 ^/ j
#include <linux/kernel.h>
* e9 o4 s Y7 X5 y# s#include <linux/types.h>
2 l# u$ a( @: \: ^#include <linux/gpio.h>
' I& J p3 L; z2 k) Z1 @1 K9 Z#include <linux/leds.h>
3 w9 t! b- ~) B k& E a#include <linux/platform_device.h>( n& ]" ^& h% ^! [0 j
7 ?, Q" }2 K8 L. C7 x! K#include <asm/mach-types.h>2 p+ v4 {' A3 O0 `& v
#include <asm/mach/arch.h>
& }4 ~6 O1 {, K/ d#include <mach/da8xx.h>5 g3 g. f; \1 D
#include <mach/mux.h>5 R$ b- \5 E7 O& \' ^& i
+ h% g8 B2 Q) `/ ?' @) ^/ K# J7 X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 d% s, A. j* I! E( @+ `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# l8 W- E' G( [% H) o9 n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# g z9 u' y% N' C6 W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: M% [+ y2 P. Y+ N- r T1 l. |
% N! [& X0 j# E( U7 v, h' H w/* assign the tl som board LED-GPIOs*/) C8 p2 {% G8 `0 f
static const short da850_evm_tl_user_led_pins[] = {
4 L: h* \' S& a, n: ? /* These pins are definition at <mach/mux.h> file */0 m! Y( P* n( b: `: M2 }5 r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( U# O4 O) U( H& r; s
-1
! @, d& J8 g; Y/ R# u; a8 _% L5 A};
n2 O+ t: E2 n7 C1 i, ^- `8 a1 Y( S, U6 v* R) h
static struct gpio_led da850_evm_tl_leds[] = {
" ]* P) w4 X! m L/ q# c" L {
8 y! ]( f/ U/ w% z* U* U% F .active_low = 0,0 V* f, U4 U- u. H
.gpio = DA850_USER_LED0,5 b7 l( X; h" N
.name = "user_led0",
z3 N8 ` p/ w( Y# k7 t7 p1 q) P .default_trigger = "default-on",
8 @4 G; F4 V3 b },5 ~! I) @9 D$ @! m, e
{
3 j- o" |/ k1 p, S! J .active_low = 0,7 r5 K/ x8 X y7 t; ?
.gpio = DA850_USER_LED1,. V3 T+ ^% U7 P Y, g
.name = "user_led1",
; I7 y' `2 \0 w# Q: z' v3 G2 `3 ? .default_trigger = "default-on",
, T# ~* B. l4 A, }) { },9 C2 K" e$ S& }
{, Q! X+ F* X; Y- B( F
.active_low = 0,
. L0 T, M( A% [' J .gpio = DA850_USER_LED2,
/ K- s o9 c! `& c" Z. W .name = "user_led2",2 J/ u+ z6 R2 O3 X
.default_trigger = "default-on",4 Z# b& D) |8 i7 _' E
},( E- N3 w3 K7 }/ j8 d- s1 G- p
{4 {4 W+ u4 _, j" k# ?
.active_low = 0,
' I: O- b) d/ i- K7 b .gpio = DA850_USER_LED3,
- O! ~3 }7 r! E8 E# s8 I .name = "user_led3",! q1 i6 n# S% p1 e! K9 Y2 `7 b
.default_trigger = "default-on",
+ a6 _ p1 `6 [, X( b. C* x },
7 z9 t9 e2 G1 ~2 k! p};
6 H x$ c7 C/ C
+ ]* G1 r, k; h. z* h4 j; G3 M6 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 A) @5 l' c. d% F8 `
.leds = da850_evm_tl_leds,$ O- O; s# `8 ^6 c4 d: S g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ P3 ]& z7 C" D' F3 S4 E};2 r3 a& E0 _5 d/ ]# I. c( ?. b: |
3 @, O6 g% W, U _0 mstatic void led_dev_release(struct device *dev)
3 p! P y- m' @{
$ E; D/ U9 r1 f. d* @6 ?9 c, l! v) M};
U$ q9 M! |( D) }. z$ Y5 n
, N( w' c Z% dstatic struct platform_device da850_evm_tl_leds_device = {
5 s. N% M8 w9 N! W. c, J l0 L- |9 y .name = "leds-gpio",
& X" d: Q- K% S s# X+ v .id = 1,% S4 H8 v) ~; X( v
.dev = {
+ F# ^: w R6 j .platform_data = &da850_evm_tl_leds_pdata,
J. h% m9 B0 V .release = led_dev_release,
/ t3 U) B; L; e' D5 Y. j }5 d: S% s' @, Q+ F
};5 Y2 T1 z3 D, I1 u. j3 F
+ }! x9 U) O9 G5 K7 [; w1 i7 Astatic int __init led_platform_init(void)$ P0 ~4 R, N# ?! y4 c( i z. x7 F
{
- H0 ^& X2 T, X: y int ret;
! ?! b& [9 a. c. X s, c#if 09 q" l* p5 S5 F6 b; \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% e; i6 k8 r7 c6 O" G; s% s* t if (ret)' n8 C0 r! S( Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". K, P1 S4 |; v( B5 \
"%d\n", ret);) r3 A: @8 t( S
#endif
* P% a- J/ W$ Y7 N8 o8 z/ N( L ret = platform_device_register(&da850_evm_tl_leds_device);
* _ @) Z# U8 q X6 @2 @# U if (ret)
! l* m2 b4 P4 S pr_warning("Could not register som GPIO expander LEDS");
) g2 g" k* a- O4 p M, t( m else1 Y3 O" k& c }$ Q
printk(KERN_INFO "LED register sucessful!\n");' X5 L% r, I7 _+ F3 i2 W# ^5 t
+ {5 x# T/ v# _$ u( U& C. j
return ret;
# ~9 T. {" t& T K9 S4 o; V}
0 D# P3 A5 W" B7 p
- v! Q5 G( K0 j( P, F! Z4 Sstatic void __exit led_platform_exit(void)( x r, x1 j. @5 A
{
7 P% l' a0 C3 }- s' E platform_device_unregister(&da850_evm_tl_leds_device);5 N( D) @* T5 s
A) e- |0 T* ~6 T$ r
printk(KERN_INFO "LED unregister!\n");
+ {5 a4 Y# d0 X; K}
" Z% ?3 ?4 h) h% X+ }" d& ^1 \0 B! ^# L& K E
module_init(led_platform_init);
8 l& n7 e1 r% t, \9 @, L- Nmodule_exit(led_platform_exit);9 z/ [5 w, G, q3 q. V/ C* F: g8 [( ?
9 O; }2 _% e1 k% ~1 ?' Y( tMODULE_DESCRIPTION("Led platform driver");* a& A# @5 x: R6 E% f
MODULE_AUTHOR("Tronlong");
) o: Q5 _# C# f. L$ SMODULE_LICENSE("GPL");# o* ^- v. @# c( K+ i$ F$ I
" f6 @/ {7 r( ^, t( P6 b8 k" G
|
|