|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 T, X- k6 X5 U
#include <linux/init.h>
& u3 D4 @6 x3 a+ a( |#include <linux/module.h>. d, X$ S6 p- E) b5 G
#include <linux/kernel.h>9 u9 i' R6 }$ W, i& b
#include <linux/types.h>
) d) a! A3 s9 ]# W#include <linux/gpio.h># Q9 g# ~2 Y. V
#include <linux/leds.h>6 n. X& l4 z9 o
#include <linux/platform_device.h>
+ G+ [7 ^& v9 z/ [4 [1 T! E4 b7 |: {" n4 }: z* I9 ?
#include <asm/mach-types.h>/ N: l" s: q. n" N" b
#include <asm/mach/arch.h>! P) T4 ^$ E; v
#include <mach/da8xx.h>
0 O. o3 k( J6 w j5 K/ X7 K1 ]7 o#include <mach/mux.h>
* Z* F% |+ F' r- }" e, }. `7 ]% b4 Y, g6 {7 T9 F) q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ h- m5 L1 u1 H R% O1 K m+ p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' N2 s9 ]1 [) }# D8 t) P8 H. ?7 k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 t9 j9 e' P6 ?1 l1 P. z# d9 z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ k) j% }8 ?2 i3 F
: v; U+ ?% R" n4 U8 W7 x. N+ G F( }/* assign the tl som board LED-GPIOs*/
2 I, @6 |. P: f/ T4 rstatic const short da850_evm_tl_user_led_pins[] = {
9 w! Z0 h( y% |$ Q" @# \0 z /* These pins are definition at <mach/mux.h> file */
/ W/ n& k9 T: i# o. T7 b( J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 ?& C) R) X e7 ?" x
-11 \' U% [, w, Q, Z I1 h- o' p
};
: y3 s! f+ g5 H& E6 b
& P- A+ v: ]$ {8 ?, S9 P5 lstatic struct gpio_led da850_evm_tl_leds[] = {- m" s+ f! r4 g, j
{# u9 m6 G7 d9 k3 R/ l: q
.active_low = 0,1 C3 _& K S A; D' j& H
.gpio = DA850_USER_LED0,
* o0 v# r, M3 M9 n& d2 E .name = "user_led0",
' u" W9 X: w2 d6 {% [$ T- J' e .default_trigger = "default-on",
$ E) M- L0 k0 A },
5 ] |6 C' h9 M! {1 { {
: Z5 |! M7 W* b4 X0 k7 Q; B( n .active_low = 0,
; a! ~# L/ k4 r5 i1 Y7 }# D2 g .gpio = DA850_USER_LED1,
1 }2 q/ Q8 C( w) D: x+ M .name = "user_led1",
2 d$ j. w- t# l/ T2 e4 l .default_trigger = "default-on", K7 @. `. [5 L3 I5 w
},' d3 v" H1 d" ^* F% D
{) r: e. u+ S* s! w8 {% ^! I
.active_low = 0,
; Y/ h4 B6 ~; _9 a .gpio = DA850_USER_LED2,
5 j# ~: j2 `0 _+ T7 ` .name = "user_led2",, B5 l# A; J0 X
.default_trigger = "default-on",
" V2 n6 x0 t5 F$ [7 `' C& { },* W8 F! O; O/ S# |
{$ M9 P2 I! p D7 ]0 ]+ k
.active_low = 0,
6 l z5 k' E$ \ y8 B+ q. O .gpio = DA850_USER_LED3,
; m$ R+ L Q& H6 J* E .name = "user_led3",
) o/ {0 v2 ~% N6 ` .default_trigger = "default-on",
" Y( o- ^; P1 c+ { },
6 k! ^4 N+ i' |: L};" c7 W+ H) p- z+ D+ i
( P5 ~+ q$ L9 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% Q% L) d' M$ u6 O
.leds = da850_evm_tl_leds,
# t1 ~9 I0 t: h3 M& \6 ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, e4 j9 l$ H1 h7 L, h: {! Q
};
" b* _2 s- i+ E5 C; R& F, c9 G$ _1 J. l+ X. n/ `1 @: r$ Q
static void led_dev_release(struct device *dev)
& r+ X' H1 x) P, m! c2 D4 E{
' v; g2 d! B& X};2 A/ K& T$ ]8 {* `! V4 D
5 D9 n- |& D; U$ B0 R8 t- Q
static struct platform_device da850_evm_tl_leds_device = {
7 T( R/ @9 W/ R1 P3 C Y" n- Y2 E .name = "leds-gpio",
3 g9 X& J8 @# _" [' d2 b$ Y9 |+ b .id = 1,* t% y. c D* y$ Z( n
.dev = {
9 S( x1 e* p3 f3 E) ?0 s' H6 f .platform_data = &da850_evm_tl_leds_pdata,1 E* t8 Q; O5 s4 D
.release = led_dev_release,) K5 u4 k# w5 f: |0 }
}
+ B% p* s4 |& j0 `% |8 a3 H};
, B D- X c5 S
- b8 j# l. O1 A }4 Estatic int __init led_platform_init(void)
: F$ @9 Q7 N- w' A{
2 v+ M/ R' v9 q5 J int ret;
7 J @& h1 r+ y$ h* w# i7 c* Y" u9 m3 B#if 06 s/ j9 V) m1 C+ P+ E# a/ R( ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; y( F- c6 i/ K* |+ s8 a if (ret)
7 O; I2 U7 @ @& r9 X K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% G% X' U: b0 K. p& O "%d\n", ret);& o6 v4 E( \! Z
#endif5 e% a$ X! j: a3 c6 I8 c. X# }
ret = platform_device_register(&da850_evm_tl_leds_device);
9 e. L" t A/ f/ Y8 s/ x2 | if (ret)
% k$ @( x5 h \ pr_warning("Could not register som GPIO expander LEDS");* i; G; J8 Q1 S
else
' L9 z: u" Y, \$ J9 U( e* j printk(KERN_INFO "LED register sucessful!\n");6 j6 H) a4 y4 [% d N$ z4 m
9 g1 k. r) c; J" B; W# L8 \
return ret;
' R r5 g$ U* F2 \, H$ m4 `( _}8 V5 z8 ]' G- h) S X
# R0 g! s# \/ p2 j- x# n
static void __exit led_platform_exit(void)% F5 }2 Y# X& @2 q$ A. _
{
8 I+ I9 r- J6 ~1 v- ^( j4 ~ platform_device_unregister(&da850_evm_tl_leds_device);# d) X& O. Q' G1 z
% O/ u' ^3 X5 G8 Q3 ]; ^9 \# ` printk(KERN_INFO "LED unregister!\n");
1 T4 d. |, A8 g% q} U$ g. }. }6 y3 d- h9 I9 h. T
- O: y. I4 P: F7 ^module_init(led_platform_init);0 s! k9 [5 M6 p3 b! O+ v
module_exit(led_platform_exit);" ^& w% C9 M& n6 a% u
4 P% R2 _( {+ ]- Q9 g+ lMODULE_DESCRIPTION("Led platform driver");' E/ s8 s% E6 @
MODULE_AUTHOR("Tronlong");2 ~, J7 `# b: o# x; B6 H
MODULE_LICENSE("GPL");0 b, d G" j; }# Y3 A! _7 {4 Q
5 D) o( U9 j& f: D3 ?& g, q
|
|