|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 u+ k5 S! |$ Z& }( p#include <linux/init.h>
4 O' `' w+ x8 _, b8 X#include <linux/module.h>
& t. `1 v9 I4 M% L; [8 q4 s: x- T* j#include <linux/kernel.h>
' Q L0 C' K z8 J8 G5 R1 e$ P0 u; s#include <linux/types.h>" v0 Z. a; Q8 c* K) [# p, g1 d- n& U
#include <linux/gpio.h>; j* q2 M% v8 F3 R% \
#include <linux/leds.h>
@, z' g5 Q: P$ ?9 F, R! u#include <linux/platform_device.h>/ L% b0 o: X" _& w' t7 f5 K% H% B8 v
1 b. p# c y$ s* t$ {; S$ R
#include <asm/mach-types.h>* f4 k) w+ F8 K( q
#include <asm/mach/arch.h>
& o3 j8 ^ L4 a4 _1 i#include <mach/da8xx.h>
* q2 [" y3 L B" V9 E+ u#include <mach/mux.h>/ P' K0 r5 L6 U$ f; o/ b" h
( s5 I* c! ^( y; |: B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 O2 Z J& K2 h( Z( {0 F' }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 T5 s% i# f! R( G3 U0 E. g0 e1 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 a4 _" |2 p$ ~1 Y! ^% o1 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" m. [4 N" @5 W `0 [3 ?% X1 R5 U
& {3 G4 v) A$ z' ~( {$ R) {/* assign the tl som board LED-GPIOs*/& {3 j& ]/ ~% w: k
static const short da850_evm_tl_user_led_pins[] = {
4 G1 F8 m" Z2 J2 [* e1 u$ o /* These pins are definition at <mach/mux.h> file */: S3 c/ ` j+ w, |0 m: H1 A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( z! Q+ C1 k& n& _2 b
-1
3 r) r( g% ?' O6 ~8 V5 _6 h) \) c};
5 p& R% N ]0 S! U4 f4 G2 a2 f, x/ g; t
static struct gpio_led da850_evm_tl_leds[] = {5 N7 L4 f2 z0 }
{
9 \! k, |4 c" D: T7 U- w .active_low = 0,% t+ _' e, [1 b& M: n6 R2 I
.gpio = DA850_USER_LED0,
. m6 I! p' G8 r .name = "user_led0",# {4 j7 Q) [6 ~ ~; y- o
.default_trigger = "default-on",
' b; ], o( l/ S! A& t5 F! c }, y! A( w3 p* l- N b" S3 L
{7 r1 _( ~4 Z7 j
.active_low = 0,8 H4 [4 @# I9 z f
.gpio = DA850_USER_LED1,
/ L5 Q1 M0 Z; [ .name = "user_led1",- e2 n+ g0 V7 d" p, F! [9 k5 q- a1 n* j
.default_trigger = "default-on",; u/ I, c. H" l1 i3 I
},
. q4 ~' T/ ^6 x) B {9 ?; y) g! K1 K; T. ?/ u. @0 D6 M* _
.active_low = 0,
' l: V% v6 R) @7 D .gpio = DA850_USER_LED2,- N! i$ O0 u0 O8 y4 F! O* ?0 e
.name = "user_led2",
- f2 Q n/ V4 Z% Z4 r$ {' H ? .default_trigger = "default-on",
( @3 ]/ c. x2 G7 X( C3 n- V" z$ { },
4 l% r, w# S* F# O {
; w* Y& N/ M* [0 P# M .active_low = 0,& M; n; ~5 P* u: r) C5 s
.gpio = DA850_USER_LED3, M# _1 d A9 U" m4 _ |
.name = "user_led3"," z ^) x& g. d
.default_trigger = "default-on",
8 N( V2 a6 F* V8 t2 o+ {# q },
% ^4 X5 Y' A; p3 j$ K$ [4 U};2 z |2 Y/ Y6 `+ |+ k: i$ v
- }! d8 C. g+ s L/ z/ H$ {& ~; [, f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 U" [8 ?' x0 N, X# ~( s. t) r
.leds = da850_evm_tl_leds,. W9 ~/ k8 v; d1 ] _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ j+ a) b! k; Z};5 j# A( w) |; V$ `
$ L, h, g0 O9 f+ Y' ?
static void led_dev_release(struct device *dev)
5 m; }+ u0 {7 @{$ C0 e# R7 O/ T( ?! m/ b a
};
, V& b! G7 n- G" l, y
6 T! X* q4 J, `static struct platform_device da850_evm_tl_leds_device = {
6 z; ^& z2 s/ o/ F) x# H .name = "leds-gpio",: }0 Q6 b* D* |
.id = 1,0 h# l' g5 f! _: |, y
.dev = {, @# j, m4 ?( D/ t6 O
.platform_data = &da850_evm_tl_leds_pdata,% S9 T2 p) ?: {3 D9 l/ D! y- w
.release = led_dev_release,
- x4 s8 }. x4 t' S. \9 m/ V }1 N" K$ [# |, ~7 D$ Y
};' v8 `' W( |( t( @, ]5 L
( d1 d+ m6 B( i0 D
static int __init led_platform_init(void)
- Y) ~( o3 j F' E{# F9 p8 R2 [% {3 e7 Q* N
int ret;
: Y5 O6 P/ N$ }2 @' |/ |#if 0
6 D5 U, c% z$ I4 m9 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 R/ m1 |3 L; ]3 n
if (ret)1 ?2 b/ }" y) p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; |) p; O# |) t2 h
"%d\n", ret);1 O1 O; `7 Z/ d3 u
#endif
* ]4 x, o% X R# N ret = platform_device_register(&da850_evm_tl_leds_device);. A4 o+ h5 ^7 P$ O0 T; j
if (ret)
9 J# u9 K8 t9 R. R pr_warning("Could not register som GPIO expander LEDS");
6 G6 V# J3 q2 ]8 Z @( z else
, F* N6 r) M" t n% A printk(KERN_INFO "LED register sucessful!\n");
9 {1 @6 D6 @6 ~" {9 Y: h# D% o; m
8 ^/ C, y6 ^! X: Q0 v2 n+ S return ret;4 J2 Q1 s- S8 \; \ d# P8 l& \( f
}% S, J3 I( m4 x) e' p8 j
' s+ P9 t) _* o* c: j6 |/ p) M
static void __exit led_platform_exit(void)2 \: [3 |! X1 O$ d! O- A
{
1 T2 c$ o: M4 k) N' A" Y2 F platform_device_unregister(&da850_evm_tl_leds_device);
1 E( \, U0 L- O0 s: ?
. F& h' i% O" R' t printk(KERN_INFO "LED unregister!\n");. D# g# @. R! s) H) W
}7 A8 h$ V1 S y8 H- h7 A) d# K
% ~7 [# p/ }. i: D) O0 I" w+ emodule_init(led_platform_init);
8 D# c8 `0 Y& f) \) Mmodule_exit(led_platform_exit);
5 l$ P- l3 ], a; E! H: G F% x' g! k% @, d6 c5 q4 |
MODULE_DESCRIPTION("Led platform driver");; u; P9 }( c9 G" G
MODULE_AUTHOR("Tronlong");
; S. N! e- Q h) h0 UMODULE_LICENSE("GPL"); }4 s5 W. M1 |" f2 d: Z
" N0 }2 F/ x. a! U |
|