|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* ^$ [; h2 q6 J* J7 T# j& p
#include <linux/init.h>
% O( v/ S& \8 h#include <linux/module.h>; {- U# S; {3 N3 V* u$ Y
#include <linux/kernel.h>
8 k4 O& P! n0 w9 z* p$ D% W# G6 P#include <linux/types.h>
K$ [4 I& f$ t H# w: [9 M#include <linux/gpio.h>
7 g3 K7 D# f# f; I#include <linux/leds.h>6 v( s/ ], i ~5 \* \! ]
#include <linux/platform_device.h>
+ A" r, R& P9 r7 i) y
' |: v( m4 x" _+ X8 X# ~( M#include <asm/mach-types.h>
) J; H' m+ h! ?. k#include <asm/mach/arch.h>8 ]: L) H: R! y- A. `8 u+ P* n
#include <mach/da8xx.h>0 k5 t/ `- ]: ^* D/ ]9 f
#include <mach/mux.h>' S' U, q$ Q) c0 o d1 q
* \6 I, z% b+ O( v. M2 m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! {3 Q! [' q& Y0 p7 K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( m6 L0 q# b& g. R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( D3 \) _5 _6 i5 C$ `; N' i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' ~" w- g+ @' ]* I
* p% T7 D* S# O; \; e/* assign the tl som board LED-GPIOs*/+ a5 |9 j% f% d) P) x7 g) T) [/ C8 P" A
static const short da850_evm_tl_user_led_pins[] = {
1 c# _ m7 Q% P0 b /* These pins are definition at <mach/mux.h> file */
% Q, i$ w$ |# P1 [3 b; h9 S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ V- `' ~* \- B7 V -1' q0 U) Q1 B+ ~: f$ g& c
};
6 b6 P9 k/ r9 L
. p! ?# K5 O# _* z6 A. C P8 o1 \static struct gpio_led da850_evm_tl_leds[] = {& J$ L& T# y. W
{9 B; w t$ v( O2 q# I+ ^& v- c
.active_low = 0,
& H2 U% q% y0 O+ b$ j) X .gpio = DA850_USER_LED0,+ h M9 ^; C; @% ?6 f
.name = "user_led0",
( h0 P5 T" k6 }7 @ .default_trigger = "default-on",# Z, w% h, Q- e7 l0 z9 w
},
0 E1 X$ `% k- o: v- R& C6 H( T {# P' ?0 L4 U# x3 z( B k1 q
.active_low = 0,
O" z& L& D0 | .gpio = DA850_USER_LED1,
% E- ]) B: }" p .name = "user_led1",
& f, k+ z4 g# @: b, J .default_trigger = "default-on",
. ^& S+ e. v0 Z- |7 ~) }+ i0 O7 y },' ^+ F% Y! N& p% d
{
8 _9 s5 O/ N2 i' b7 u# U' k9 L .active_low = 0,
+ y6 Q% }$ d# `5 e2 K .gpio = DA850_USER_LED2,
' x7 l; ?3 y1 F! b6 U .name = "user_led2",
5 S; d8 p' h; z5 w! x .default_trigger = "default-on",
; E- K. l7 q- r7 {0 A1 G5 A2 } },
2 H5 V6 F- d- {, B {: J# ]) U" X6 j; }
.active_low = 0,) N0 a# r! ~5 j
.gpio = DA850_USER_LED3,
3 x& I( u( J- b' S: r$ w .name = "user_led3",
, {, ]$ B! n$ I! M .default_trigger = "default-on",- G0 \5 s8 L* Y; n! i- K/ v* I
},
% U8 _! b' X: ~6 L9 d: N( ?& O J* j};
+ o8 S6 `( a% g6 `4 u1 p' A- ]/ M+ T. K! ?( K0 f& A3 j( I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 M7 `( l( H# S0 O: K. w
.leds = da850_evm_tl_leds,
; z o3 N; J W0 e' N6 `. q- b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 }8 z# L$ B8 L$ a; a2 {
};
# ?- Q2 _/ {$ n
# ~) W# i \" K7 w" N! p9 Ustatic void led_dev_release(struct device *dev)
2 s X" u+ {6 q# z2 {{
8 _2 f7 u8 _6 t6 g* F# e};
$ S3 H0 c) n6 ], {
& K, V. {. v1 H+ ^static struct platform_device da850_evm_tl_leds_device = {
" s4 i$ K8 L7 E .name = "leds-gpio",
1 K, N, t5 c4 ], J |- t9 l Q .id = 1,0 Q& z. I7 {4 ^- q' r$ m
.dev = {
* \9 ~9 U' H& s C7 R; M .platform_data = &da850_evm_tl_leds_pdata,0 F1 K( G/ z8 `2 O# X F* Y* U" P% I
.release = led_dev_release,7 _5 v/ y% Y3 A# C5 j& U5 H
}
6 ]; ^. u7 l7 @- v/ ]& T, {( {4 p; _};
3 ^, l$ L) J: e4 A! e d! S V3 M" ^: ?% x7 w9 z2 o* T, Y
static int __init led_platform_init(void) x( _4 r3 x9 f9 j1 y
{ P/ o7 \' z: n( T' A
int ret;
3 r9 u/ R3 f! J8 {#if 08 c( a' L4 {% _2 t! m+ y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ [% L" B5 e: Y) T2 A/ U8 P
if (ret)
$ l0 d7 C" B% C( ^0 N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( E$ m$ e- E9 y" t- g( h4 I "%d\n", ret);
; ~0 d! E3 a! u1 |#endif$ ~: O, d1 |2 g" X
ret = platform_device_register(&da850_evm_tl_leds_device);# K' l6 T0 ?' U
if (ret)4 l& R6 G$ ^ b' D! F( E
pr_warning("Could not register som GPIO expander LEDS");
6 d% v; V" q) V0 ^" O else
2 z' C3 P9 Q1 \* R3 z printk(KERN_INFO "LED register sucessful!\n");
- C6 W! Z9 [/ n
( t6 p5 G1 \8 q+ R# r& p! y4 X' \ return ret;3 E, i' I4 _( `* `
}, b1 f& h ~% i% D# \
0 r1 D: B, `3 ?" u' k& {static void __exit led_platform_exit(void)
; L2 ?$ k0 x8 S$ `2 A* N{
' Q2 D( }* G. Y z; d' y platform_device_unregister(&da850_evm_tl_leds_device);
7 @0 Y; `! t: ~% N# B8 M3 q" b
& h# E2 k$ U K K printk(KERN_INFO "LED unregister!\n");/ p4 i1 N! K5 y/ O# Z% b$ Y, C- Q1 A! u
}* U4 h; M1 _$ i
2 Y( J T5 b6 Z" y7 F7 X- T
module_init(led_platform_init);
" x6 a- k' a# Lmodule_exit(led_platform_exit);$ H2 r, e: Z5 h8 h- t1 ?% a+ c2 q: D
0 B, f3 a$ |+ Y( Z
MODULE_DESCRIPTION("Led platform driver");
8 r# i) Y# h$ O, A+ wMODULE_AUTHOR("Tronlong");6 q3 q D% r: h/ \0 F4 i* g+ o
MODULE_LICENSE("GPL");
0 o* z: F* p" e, i' s2 ]* l, i* Y& k' _( k* K5 F+ G0 I
|
|