|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' J3 l# o9 [! s6 b2 y5 A8 Z- r#include <linux/init.h>
& t7 r# k! o- c0 I/ U1 b#include <linux/module.h>" k% V" ~# g2 C
#include <linux/kernel.h>0 Q2 M6 M4 x" k0 P7 R0 n C
#include <linux/types.h>6 h8 ^- c. Z4 Q# R
#include <linux/gpio.h>
2 m8 r. u0 h& P. e( V3 S: F" M; u4 D#include <linux/leds.h>
( P5 D( q5 u" k8 {% Z7 c#include <linux/platform_device.h>0 L2 i" I1 h+ T1 `" K. {1 P; x: _2 L
E* v, C R* `1 H- x7 w( k) s0 p#include <asm/mach-types.h>/ N& g: v7 e; L
#include <asm/mach/arch.h>
4 R3 |5 I }2 |- d: V; a- A#include <mach/da8xx.h>8 O @. n9 {0 M- V( D& V# ^
#include <mach/mux.h>* e4 I# \8 O# q5 t
; @* k2 u7 f; G% M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 M, C$ x# w* ?, ^- P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! {) k( f4 ~% X, _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- n4 O# _7 O H1 M: k+ J0 e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. H0 S9 j8 {/ O+ @7 k; G: ~6 x1 p6 q# S
/* assign the tl som board LED-GPIOs*/$ {3 \( Y$ s4 }, m7 Q2 P1 t2 L8 h: ?: p
static const short da850_evm_tl_user_led_pins[] = {( |, T( Q7 m% `
/* These pins are definition at <mach/mux.h> file */5 f7 y# n# I: D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 G% D- @% f( q3 G$ ` -1+ o& w3 W1 O, m. o
};+ D, r' ?1 Z0 U$ J
+ ]& L' W3 D6 m/ K9 N9 x$ [8 O& F
static struct gpio_led da850_evm_tl_leds[] = {: V5 F" o( Z0 A4 A' v2 _' n+ [
{. j5 q; v, W) p9 d2 \8 ~
.active_low = 0,8 ], f5 J4 p% x7 j1 A* U
.gpio = DA850_USER_LED0,
+ N" N: V& `9 ?7 \0 m .name = "user_led0",9 _5 g% Q5 g0 f6 B
.default_trigger = "default-on",
( |( d9 `9 p. y8 s },
2 d5 L1 u: U9 y6 ?* M- L" e8 ` {+ E% [& j0 W. ^, `& F
.active_low = 0,/ j, g" ]3 [+ J. N h' m
.gpio = DA850_USER_LED1, h$ |1 x x$ D+ a$ u/ s# l
.name = "user_led1",6 W, v# x4 s( x4 L% G/ n: P6 |
.default_trigger = "default-on",
/ e H6 n' Z2 O$ U. ~7 Q },
3 s# t. i( n1 I, e* P8 t7 A {5 U) T* b# a1 _2 {
.active_low = 0,
7 {% g) R6 Z; i$ r8 G .gpio = DA850_USER_LED2,
3 D- [ a `" J" O# {4 z/ j8 f .name = "user_led2",; o" p- V1 n3 `3 o1 p* R' g
.default_trigger = "default-on",! b0 e% }) z# u) V3 ~: u
},: `" r3 y& g& u0 v+ M) w
{4 J7 x3 s0 v+ ^% ?; D3 S# L" s
.active_low = 0,
& W/ R! s0 l9 \, h8 @8 N: j- Q+ I .gpio = DA850_USER_LED3,
4 U- T% G7 m. \' a( @# a3 ]' O' V .name = "user_led3",& U5 P) P0 k9 p% Y1 n
.default_trigger = "default-on",
; @! ]/ S8 P% c+ ]0 z },
, f% X1 W" Y2 ]- O; K% d( X6 R; s};
8 B3 X) o: x3 ?+ u
0 ~" U& Q; b2 v! Y# ~1 ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ K% ]) [$ B6 y5 [# ` .leds = da850_evm_tl_leds,
7 N1 i) d* r6 U0 n1 K' z6 {1 \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! J* L. ?8 a2 B: O: M
};
9 ?3 V, [9 v$ w; }# d0 g* ]$ z8 v: a! U
static void led_dev_release(struct device *dev)
- b" i4 N. M0 A1 |{# Q9 n9 J) M3 h- ]# @6 M7 Q
};# Z, \( E% L, V. h$ r& P! R2 I
7 ~8 ^+ S: Y0 d: L/ h
static struct platform_device da850_evm_tl_leds_device = {
/ |0 T3 r; ?$ i: n% j .name = "leds-gpio",) ?) w: [9 f6 u$ |1 S7 f
.id = 1,$ i5 H, K8 o6 T1 O [, F6 ^
.dev = {6 z4 a `9 m) [3 U+ C5 U" B! m2 Y5 V
.platform_data = &da850_evm_tl_leds_pdata,
4 Z* z3 N, X3 V8 [- }9 P .release = led_dev_release,, A& d% u/ b& f; Y& |7 Y
}
& Y* l, i; j5 E' p r: l};
2 c# t6 W* U; |: V: j" e) _5 x
: w4 N8 g$ D, J- T* O8 c" M: Y- ^, Gstatic int __init led_platform_init(void)0 q, K4 b0 b4 x/ T1 j& `% h
{6 D5 \- e w& h H
int ret;& U6 ]& B" J- E; b( J2 H
#if 0
# o0 K8 g0 b- P+ p& t! v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% s* D$ }2 Y( w! x( G& e! \
if (ret)0 ?; m- Y0 Q( k8 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" h$ e4 d7 n5 f: m* C1 X; N
"%d\n", ret);0 B0 T. k3 L1 j0 y2 l2 \% U
#endif5 `" b% l, y6 U4 j* H5 j) _
ret = platform_device_register(&da850_evm_tl_leds_device);
- k, p' P, k( U# s7 h. W if (ret)* c2 r7 R9 i4 T
pr_warning("Could not register som GPIO expander LEDS");
! D1 u9 @6 P2 [5 p' w" ] else& S1 b4 J1 p$ T2 D5 \% n
printk(KERN_INFO "LED register sucessful!\n");
# C" j0 b+ n5 f& q& L3 F4 i3 Q9 t
return ret;
: L' _; W z; n9 X/ U `}/ X/ u7 b- I2 u& f$ H
0 n [: r+ }: P% [- f( i3 a+ [static void __exit led_platform_exit(void) u4 E) Z' F7 q; O2 E" f
{
# W6 L8 ]8 c" j* u% B0 E platform_device_unregister(&da850_evm_tl_leds_device);
6 }+ E& t: l7 b* g' ]: E! u* C Q8 W1 H5 i6 l; N' S, g
printk(KERN_INFO "LED unregister!\n");
$ g6 s% @% {$ X}
/ z* e) |0 J4 E, F) ]9 k) C O/ u _6 _7 z4 ?1 \# ?
module_init(led_platform_init);4 j/ t: |8 q( B4 q
module_exit(led_platform_exit);
1 w. t# m: ?' k
i9 Y/ r, M$ FMODULE_DESCRIPTION("Led platform driver");( X- Y( r' `$ u3 V% V! F& X
MODULE_AUTHOR("Tronlong");. J9 o- q0 M% B4 i
MODULE_LICENSE("GPL");
& B1 q* k. r! d+ P8 ~% ~5 k
- `+ q1 B: c3 X! W |
|